diff options
author | Winnie Hellmann <winnie@gitlab.com> | 2017-12-19 15:20:06 +0300 |
---|---|---|
committer | Winnie Hellmann <winnie@gitlab.com> | 2017-12-21 00:00:46 +0300 |
commit | 408b56bd948edc80b212cd8025bbbee921c69d6b (patch) | |
tree | abe7781875c65595643a119f6e4e83f3bf765007 /spec/javascripts/merge_request_tabs_spec.js | |
parent | e0a27ee419b55509204ba2bfbdbfbab3c7c331bc (diff) |
Fix racing condition in Ajax call of merge_request_tabs_spec.js
Diffstat (limited to 'spec/javascripts/merge_request_tabs_spec.js')
-rw-r--r-- | spec/javascripts/merge_request_tabs_spec.js | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/spec/javascripts/merge_request_tabs_spec.js b/spec/javascripts/merge_request_tabs_spec.js index 050f0ea9ebd..a6be474805b 100644 --- a/spec/javascripts/merge_request_tabs_spec.js +++ b/spec/javascripts/merge_request_tabs_spec.js @@ -290,15 +290,18 @@ import 'vendor/jquery.scrollTo'; $('body').removeAttr('data-page'); }); - it('requires an absolute pathname', function () { - spyOn($, 'ajax').and.callFake(function (options) { - expect(options.url).toEqual('/foo/bar/merge_requests/1/diffs.json'); + it('triggers Ajax request to JSON endpoint', function (done) { + const url = '/foo/bar/merge_requests/1/diffs'; + spyOn(this.class, 'ajaxGet').and.callFake((options) => { + expect(options.url).toEqual(`${url}.json`); + done(); }); - this.class.loadDiff('/foo/bar/merge_requests/1/diffs'); + this.class.loadDiff(url); }); - it('triggers scroll event when diff already loaded', function () { + it('triggers scroll event when diff already loaded', function (done) { + spyOn(this.class, 'ajaxGet').and.callFake(() => done.fail()); spyOn(document, 'dispatchEvent'); this.class.diffsLoaded = true; @@ -307,6 +310,7 @@ import 'vendor/jquery.scrollTo'; expect( document.dispatchEvent, ).toHaveBeenCalledWith(new CustomEvent('scroll')); + done(); }); describe('with inline diff', () => { |