Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
61a1675b
Commit
61a1675b
authored
Aug 13, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
76129fce
b24359e2
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
20 deletions
+53
-20
spec/frontend/environments/confirm_rollback_modal_spec.js
spec/frontend/environments/confirm_rollback_modal_spec.js
+1
-1
spec/frontend/environments/environment_rollback_spec.js
spec/frontend/environments/environment_rollback_spec.js
+11
-19
spec/frontend/matchers.js
spec/frontend/matchers.js
+38
-0
spec/frontend/test_setup.js
spec/frontend/test_setup.js
+3
-0
No files found.
spec/
javascripts
/environments/confirm_rollback_modal_spec.js
→
spec/
frontend
/environments/confirm_rollback_modal_spec.js
View file @
61a1675b
...
...
@@ -61,7 +61,7 @@ describe('Confirm Rollback Modal Component', () => {
environment
,
},
});
const
eventHubSpy
=
spyOn
(
eventHub
,
'
$emit
'
);
const
eventHubSpy
=
jest
.
spyOn
(
eventHub
,
'
$emit
'
);
const
modal
=
component
.
find
(
GlModal
);
modal
.
vm
.
$emit
(
'
ok
'
);
...
...
spec/
javascripts
/environments/environment_rollback_spec.js
→
spec/
frontend
/environments/environment_rollback_spec.js
View file @
61a1675b
import
Vue
from
'
vue
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
,
mount
}
from
'
@vue/test-utils
'
;
import
{
GlButton
}
from
'
@gitlab/ui
'
;
import
eventHub
from
'
~/environments/event_hub
'
;
import
rollbackComp
from
'
~/environments/components/environment_rollback.vue
'
;
import
RollbackComponent
from
'
~/environments/components/environment_rollback.vue
'
;
describe
(
'
Rollback Component
'
,
()
=>
{
const
retryUrl
=
'
https://gitlab.com/retry
'
;
let
RollbackComponent
;
beforeEach
(()
=>
{
RollbackComponent
=
Vue
.
extend
(
rollbackComp
);
});
it
(
'
Should render Re-deploy label when isLastDeployment is true
'
,
()
=>
{
const
component
=
new
RollbackComponent
({
el
:
document
.
querySelector
(
'
.test-dom-element
'
),
const
wrapper
=
mount
(
RollbackComponent
,
{
propsData
:
{
retryUrl
,
isLastDeployment
:
true
,
environment
:
{},
},
})
.
$mount
()
;
});
expect
(
component
.
$el
).
toHaveSpriteIcon
(
'
repeat
'
);
expect
(
wrapper
.
element
).
toHaveSpriteIcon
(
'
repeat
'
);
});
it
(
'
Should render Rollback label when isLastDeployment is false
'
,
()
=>
{
const
component
=
new
RollbackComponent
({
el
:
document
.
querySelector
(
'
.test-dom-element
'
),
const
wrapper
=
mount
(
RollbackComponent
,
{
propsData
:
{
retryUrl
,
isLastDeployment
:
false
,
environment
:
{},
},
})
.
$mount
()
;
});
expect
(
component
.
$el
).
toHaveSpriteIcon
(
'
redo
'
);
expect
(
wrapper
.
element
).
toHaveSpriteIcon
(
'
redo
'
);
});
it
(
'
should emit a "rollback" event on button click
'
,
()
=>
{
const
eventHubSpy
=
spyOn
(
eventHub
,
'
$emit
'
);
const
component
=
shallowMount
(
RollbackComponent
,
{
const
eventHubSpy
=
jest
.
spyOn
(
eventHub
,
'
$emit
'
);
const
wrapper
=
shallowMount
(
RollbackComponent
,
{
propsData
:
{
retryUrl
,
environment
:
{
...
...
@@ -48,7 +40,7 @@ describe('Rollback Component', () => {
},
},
});
const
button
=
component
.
find
(
GlButton
);
const
button
=
wrapper
.
find
(
GlButton
);
button
.
vm
.
$emit
(
'
click
'
);
...
...
spec/frontend/matchers.js
0 → 100644
View file @
61a1675b
export
default
{
toHaveSpriteIcon
:
(
element
,
iconName
)
=>
{
if
(
!
iconName
)
{
throw
new
Error
(
'
toHaveSpriteIcon is missing iconName argument!
'
);
}
if
(
!
(
element
instanceof
HTMLElement
))
{
throw
new
Error
(
`
${
element
}
is not a DOM element!`
);
}
const
iconReferences
=
[].
slice
.
apply
(
element
.
querySelectorAll
(
'
svg use
'
));
const
matchingIcon
=
iconReferences
.
find
(
reference
=>
reference
.
getAttribute
(
'
xlink:href
'
).
endsWith
(
`#
${
iconName
}
`
),
);
const
pass
=
Boolean
(
matchingIcon
);
let
message
;
if
(
pass
)
{
message
=
`
${
element
.
outerHTML
}
contains the sprite icon "
${
iconName
}
"!`
;
}
else
{
message
=
`
${
element
.
outerHTML
}
does not contain the sprite icon "
${
iconName
}
"!`
;
const
existingIcons
=
iconReferences
.
map
(
reference
=>
{
const
iconUrl
=
reference
.
getAttribute
(
'
xlink:href
'
);
return
`"
${
iconUrl
.
replace
(
/^.+#/
,
''
)}
"`
;
});
if
(
existingIcons
.
length
>
0
)
{
message
+=
` (only found
${
existingIcons
.
join
(
'
,
'
)}
)`
;
}
}
return
{
pass
,
message
:
()
=>
message
,
};
},
};
spec/frontend/test_setup.js
View file @
61a1675b
...
...
@@ -6,6 +6,7 @@ import { config as testUtilsConfig } from '@vue/test-utils';
import
{
initializeTestTimeout
}
from
'
./helpers/timeout
'
;
import
{
loadHTMLFixture
,
setHTMLFixture
}
from
'
./helpers/fixtures
'
;
import
{
setupManualMocks
}
from
'
./mocks/mocks_helper
'
;
import
customMatchers
from
'
./matchers
'
;
// Expose jQuery so specs using jQuery plugins can be imported nicely.
// Here is an issue to explore better alternatives:
...
...
@@ -67,6 +68,8 @@ Object.entries(jqueryMatchers).forEach(([matcherName, matcherFactory]) => {
});
});
expect
.
extend
(
customMatchers
);
// Tech debt issue TBD
testUtilsConfig
.
logModifiedComponents
=
false
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment