diff options
author | Phil Hughes <me@iamphill.com> | 2018-01-29 17:29:08 +0300 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2018-01-29 17:29:08 +0300 |
commit | 2b66879ea2ae8ac3ae7015eb2b083770f973ad4e (patch) | |
tree | 3f4416ff8ccfe4df54015b5f43bacd1b09092e42 /spec/javascripts/issuable_spec.js | |
parent | 0c2c8773fbcad9b837500b12f01de754e4bd36a6 (diff) |
fixed issuable_spec.js
Diffstat (limited to 'spec/javascripts/issuable_spec.js')
-rw-r--r-- | spec/javascripts/issuable_spec.js | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/spec/javascripts/issuable_spec.js b/spec/javascripts/issuable_spec.js index 5a9112716f4..d53ffecbd35 100644 --- a/spec/javascripts/issuable_spec.js +++ b/spec/javascripts/issuable_spec.js @@ -1,3 +1,5 @@ +import MockAdaptor from 'axios-mock-adapter'; +import axios from '~/lib/utils/axios_utils'; import IssuableIndex from '~/issuable_index'; describe('Issuable', () => { @@ -19,6 +21,8 @@ describe('Issuable', () => { }); describe('resetIncomingEmailToken', () => { + let mock; + beforeEach(() => { const element = document.createElement('a'); element.classList.add('incoming-email-token-reset'); @@ -30,14 +34,28 @@ describe('Issuable', () => { document.body.appendChild(input); Issuable = new IssuableIndex('issue_'); + + mock = new MockAdaptor(axios); + + mock.onPut('foo').reply(200, { + new_address: 'testing123', + }); }); - it('should send request to reset email token', () => { - spyOn(jQuery, 'ajax').and.callThrough(); + afterEach(() => { + mock.restore(); + }); + + it('should send request to reset email token', (done) => { + spyOn(axios, 'put').and.callThrough(); document.querySelector('.incoming-email-token-reset').click(); - expect(jQuery.ajax).toHaveBeenCalled(); - expect(jQuery.ajax.calls.argsFor(0)[0].url).toEqual('foo'); + setTimeout(() => { + expect(axios.put).toHaveBeenCalledWith('foo'); + expect($('#issuable_email').val()).toBe('testing123'); + + done(); + }); }); }); }); |