diff options
author | Phil Hughes <me@iamphill.com> | 2018-02-02 14:16:57 +0300 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2018-02-05 12:41:00 +0300 |
commit | 015e15f4e8a55782e7ab9acf3ffee928a02313ec (patch) | |
tree | 254104a15f5ba59537b056c939a4d4865e790c59 /spec/javascripts/right_sidebar_spec.js | |
parent | deaf6aee2bf0aa0d87a70f536a1064eded573b6b (diff) |
Converted right_sidebar.js to use axios
Diffstat (limited to 'spec/javascripts/right_sidebar_spec.js')
-rw-r--r-- | spec/javascripts/right_sidebar_spec.js | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/spec/javascripts/right_sidebar_spec.js b/spec/javascripts/right_sidebar_spec.js index 3267e29585b..84659ee91b3 100644 --- a/spec/javascripts/right_sidebar_spec.js +++ b/spec/javascripts/right_sidebar_spec.js @@ -1,6 +1,8 @@ /* eslint-disable space-before-function-paren, no-var, one-var, one-var-declaration-per-line, new-parens, no-return-assign, new-cap, vars-on-top, max-len */ +import MockAdapter from 'axios-mock-adapter'; import '~/commons/bootstrap'; +import axios from '~/lib/utils/axios_utils'; import Sidebar from '~/right_sidebar'; (function() { @@ -35,10 +37,12 @@ import Sidebar from '~/right_sidebar'; var fixtureName = 'issues/open-issue.html.raw'; preloadFixtures(fixtureName); loadJSONFixtures('todos/todos.json'); + let mock; beforeEach(function() { loadFixtures(fixtureName); - this.sidebar = new Sidebar; + mock = new MockAdapter(axios); + this.sidebar = new Sidebar(); $aside = $('.right-sidebar'); $page = $('.layout-page'); $icon = $aside.find('i'); @@ -63,20 +67,20 @@ import Sidebar from '~/right_sidebar'; return assertSidebarState('collapsed'); }); - it('should broadcast todo:toggle event when add todo clicked', function() { + it('should broadcast todo:toggle event when add todo clicked', function(done) { var todos = getJSONFixture('todos/todos.json'); - spyOn(jQuery, 'ajax').and.callFake(function() { - var d = $.Deferred(); - var response = todos; - d.resolve(response); - return d.promise(); - }); + spyOn(axios, 'get').and.callThrough(); + mock.onAny(`${gl.TEST_HOST}/frontend-fixtures/issues-project/todos`).reply(200, todos); var todoToggleSpy = spyOnEvent(document, 'todo:toggle'); $('.issuable-sidebar-header .js-issuable-todo').click(); - expect(todoToggleSpy.calls.count()).toEqual(1); + setTimeout(() => { + expect(todoToggleSpy.calls.count()).toEqual(1); + + done(); + }); }); it('should not hide collapsed icons', () => { |