Commit d284f678 authored by Mike Greiling's avatar Mike Greiling

fix timing issues in karma tests

parent 76585993
...@@ -26,7 +26,7 @@ const issuable2 = { ...@@ -26,7 +26,7 @@ const issuable2 = {
destroy_relation_path: '/foo/bar/issues/124/related_issues/1', destroy_relation_path: '/foo/bar/issues/124/related_issues/1',
}; };
describe('RelatedIssuesRoot', () => { fdescribe('RelatedIssuesRoot', () => {
let RelatedIssuesRoot; let RelatedIssuesRoot;
let vm; let vm;
...@@ -138,6 +138,7 @@ describe('RelatedIssuesRoot', () => { ...@@ -138,6 +138,7 @@ describe('RelatedIssuesRoot', () => {
describe('onPendingFormSubmit', () => { describe('onPendingFormSubmit', () => {
beforeEach(() => { beforeEach(() => {
spyOn(relatedIssuesService.prototype, 'fetchRelatedIssues').and.returnValue(Promise.reject());
vm = new RelatedIssuesRoot({ vm = new RelatedIssuesRoot({
propsData: defaultProps, propsData: defaultProps,
}).$mount(); }).$mount();
...@@ -250,23 +251,21 @@ describe('RelatedIssuesRoot', () => { ...@@ -250,23 +251,21 @@ describe('RelatedIssuesRoot', () => {
}); });
describe('fetchRelatedIssues', () => { describe('fetchRelatedIssues', () => {
beforeEach(() => { beforeEach((done) => {
vm = new RelatedIssuesRoot({ vm = new RelatedIssuesRoot({
propsData: defaultProps, propsData: defaultProps,
}).$mount(); }).$mount();
// wait for internal call to fetchRelatedIssues to resolve
setTimeout(() => Vue.nextTick(done));
}); });
describe('when the network has not responded yet', () => { describe('when the network has not responded yet', () => {
it('should be fetching', (done) => { it('should be fetching', (done) => {
vm.fetchRelatedIssues(); vm.fetchRelatedIssues();
setTimeout(() => {
Vue.nextTick(() => {
expect(vm.isFetching).toEqual(true); expect(vm.isFetching).toEqual(true);
done(); setTimeout(() => Vue.nextTick(done));
});
});
}); });
}); });
......
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