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
028aaed1
Commit
028aaed1
authored
Dec 23, 2020
by
Illya Klymov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove deprecated `methods` usage
Replace `methods` usage with action mocks
parent
4ab9b3ea
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
28 deletions
+9
-28
spec/frontend/alerts_service_settings/components/alerts_service_form_spec.js
...s_service_settings/components/alerts_service_form_spec.js
+9
-28
No files found.
spec/frontend/alerts_service_settings/components/alerts_service_form_spec.js
View file @
028aaed1
import
{
nextTick
}
from
'
vue
'
;
import
axios
from
'
axios
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
...
...
@@ -22,13 +23,12 @@ describe('AlertsServiceForm', () => {
let
wrapper
;
let
mockAxios
;
const
createComponent
=
(
props
=
defaultProps
,
{
methods
}
=
{}
)
=>
{
const
createComponent
=
(
props
=
defaultProps
)
=>
{
wrapper
=
shallowMount
(
AlertsServiceForm
,
{
propsData
:
{
...
defaultProps
,
...
props
,
},
methods
,
});
};
...
...
@@ -75,25 +75,16 @@ describe('AlertsServiceForm', () => {
});
describe
(
'
reset key
'
,
()
=>
{
it
(
'
triggers resetKey method
'
,
()
=>
{
const
resetKey
=
jest
.
fn
();
const
methods
=
{
resetKey
};
createComponent
(
defaultProps
,
{
methods
});
wrapper
.
find
(
GlModal
).
vm
.
$emit
(
'
ok
'
);
expect
(
resetKey
).
toHaveBeenCalled
();
});
it
(
'
updates the authorization key on success
'
,
()
=>
{
it
(
'
updates the authorization key on success
'
,
async
()
=>
{
const
formPath
=
'
some/path
'
;
mockAxios
.
onPut
(
formPath
,
{
service
:
{
token
:
''
}
}
).
replyOnce
(
200
,
{
token
:
'
newToken
'
});
mockAxios
.
onPut
(
formPath
).
replyOnce
(
200
,
{
token
:
'
newToken
'
});
createComponent
({
formPath
});
return
wrapper
.
vm
.
resetKey
().
then
(()
=>
{
expect
(
findAuthorizationKey
().
attributes
(
'
value
'
)).
toBe
(
'
newToken
'
);
});
wrapper
.
find
(
GlModal
).
vm
.
$emit
(
'
ok
'
);
await
axios
.
waitForAll
();
expect
(
findAuthorizationKey
().
attributes
(
'
value
'
)).
toBe
(
'
newToken
'
);
});
it
(
'
shows flash message on error
'
,
()
=>
{
...
...
@@ -112,16 +103,6 @@ describe('AlertsServiceForm', () => {
});
describe
(
'
activate toggle
'
,
()
=>
{
it
(
'
triggers toggleActivated method
'
,
()
=>
{
const
toggleActivated
=
jest
.
fn
();
const
methods
=
{
toggleActivated
};
createComponent
(
defaultProps
,
{
methods
});
wrapper
.
find
(
ToggleButton
).
vm
.
$emit
(
'
change
'
,
true
);
expect
(
toggleActivated
).
toHaveBeenCalled
();
});
describe
(
'
successfully completes
'
,
()
=>
{
describe
.
each
`
initialActivated | value
...
...
@@ -175,7 +156,7 @@ describe('AlertsServiceForm', () => {
it
(
'
cannot be toggled
'
,
()
=>
{
wrapper
.
find
(
ToggleButton
).
vm
.
$emit
(
'
change
'
);
return
wrapper
.
vm
.
$
nextTick
().
then
(()
=>
{
return
nextTick
().
then
(()
=>
{
expect
(
wrapper
.
find
(
ToggleButton
).
props
(
'
disabledInput
'
)).
toBe
(
true
);
});
});
...
...
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