Commit f00c6db8 authored by Fatih Acet's avatar Fatih Acet

Add new spec for updateStoreState method

parent 4e40d72a
......@@ -212,9 +212,8 @@ export default {
}
return undefined;
},
updateStoreState() {
this.service
return this.service
.getData()
.then(res => res.data)
.then(data => {
......@@ -252,12 +251,9 @@ export default {
if (window.location.pathname !== data.web_url) {
visitUrl(data.web_url);
}
return this.service.getData();
})
.then(res => res.data)
.then(data => {
this.store.updateState(data);
.then(this.updateStoreState)
.then(() => {
eventHub.$emit('close.form');
})
.catch(error => {
......
......@@ -140,6 +140,7 @@ describe('Issuable output', () => {
describe('updateIssuable', () => {
it('fetches new data after update', done => {
spyOn(vm, 'updateStoreState').and.callThrough();
spyOn(vm.service, 'getData').and.callThrough();
spyOn(vm.service, 'updateIssuable').and.callFake(
() =>
......@@ -155,6 +156,7 @@ describe('Issuable output', () => {
vm.updateIssuable()
.then(() => {
expect(vm.updateStoreState).toHaveBeenCalled();
expect(vm.service.getData).toHaveBeenCalled();
})
.then(done)
......@@ -452,4 +454,20 @@ describe('Issuable output', () => {
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);
});
});
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment