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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
f00c6db8
Commit
f00c6db8
authored
Jan 26, 2019
by
Fatih Acet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new spec for updateStoreState method
parent
4e40d72a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
7 deletions
+21
-7
app/assets/javascripts/issue_show/components/app.vue
app/assets/javascripts/issue_show/components/app.vue
+3
-7
spec/javascripts/issue_show/components/app_spec.js
spec/javascripts/issue_show/components/app_spec.js
+18
-0
No files found.
app/assets/javascripts/issue_show/components/app.vue
View file @
f00c6db8
...
@@ -212,9 +212,8 @@ export default {
...
@@ -212,9 +212,8 @@ export default {
}
}
return
undefined
;
return
undefined
;
},
},
updateStoreState
()
{
updateStoreState
()
{
this
.
service
return
this
.
service
.
getData
()
.
getData
()
.
then
(
res
=>
res
.
data
)
.
then
(
res
=>
res
.
data
)
.
then
(
data
=>
{
.
then
(
data
=>
{
...
@@ -252,12 +251,9 @@ export default {
...
@@ -252,12 +251,9 @@ export default {
if
(
window
.
location
.
pathname
!==
data
.
web_url
)
{
if
(
window
.
location
.
pathname
!==
data
.
web_url
)
{
visitUrl
(
data
.
web_url
);
visitUrl
(
data
.
web_url
);
}
}
return
this
.
service
.
getData
();
})
})
.
then
(
res
=>
res
.
data
)
.
then
(
this
.
updateStoreState
)
.
then
(
data
=>
{
.
then
(()
=>
{
this
.
store
.
updateState
(
data
);
eventHub
.
$emit
(
'
close.form
'
);
eventHub
.
$emit
(
'
close.form
'
);
})
})
.
catch
(
error
=>
{
.
catch
(
error
=>
{
...
...
spec/javascripts/issue_show/components/app_spec.js
View file @
f00c6db8
...
@@ -140,6 +140,7 @@ describe('Issuable output', () => {
...
@@ -140,6 +140,7 @@ describe('Issuable output', () => {
describe
(
'
updateIssuable
'
,
()
=>
{
describe
(
'
updateIssuable
'
,
()
=>
{
it
(
'
fetches new data after update
'
,
done
=>
{
it
(
'
fetches new data after update
'
,
done
=>
{
spyOn
(
vm
,
'
updateStoreState
'
).
and
.
callThrough
();
spyOn
(
vm
.
service
,
'
getData
'
).
and
.
callThrough
();
spyOn
(
vm
.
service
,
'
getData
'
).
and
.
callThrough
();
spyOn
(
vm
.
service
,
'
updateIssuable
'
).
and
.
callFake
(
spyOn
(
vm
.
service
,
'
updateIssuable
'
).
and
.
callFake
(
()
=>
()
=>
...
@@ -155,6 +156,7 @@ describe('Issuable output', () => {
...
@@ -155,6 +156,7 @@ describe('Issuable output', () => {
vm
.
updateIssuable
()
vm
.
updateIssuable
()
.
then
(()
=>
{
.
then
(()
=>
{
expect
(
vm
.
updateStoreState
).
toHaveBeenCalled
();
expect
(
vm
.
service
.
getData
).
toHaveBeenCalled
();
expect
(
vm
.
service
.
getData
).
toHaveBeenCalled
();
})
})
.
then
(
done
)
.
then
(
done
)
...
@@ -452,4 +454,20 @@ describe('Issuable output', () => {
...
@@ -452,4 +454,20 @@ describe('Issuable output', () => {
expect
(
vm
.
$el
.
querySelector
(
'
.title-container .note-action-button
'
)).
toBeDefined
();
expect
(
vm
.
$el
.
querySelector
(
'
.title-container .note-action-button
'
)).
toBeDefined
();
});
});
});
});
describe
(
'
updateStoreState
'
,
()
=>
{
it
(
'
should make a request and update the state of the store
'
,
done
=>
{
const
data
=
{
foo
:
1
};
spyOn
(
vm
.
store
,
'
updateState
'
);
spyOn
(
vm
.
service
,
'
getData
'
).
and
.
returnValue
(
Promise
.
resolve
({
data
}));
vm
.
updateStoreState
()
.
then
(()
=>
{
expect
(
vm
.
service
.
getData
).
toHaveBeenCalled
();
expect
(
vm
.
store
.
updateState
).
toHaveBeenCalledWith
(
data
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
});
});
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