2018-03-09 15:18:59 -05:00
|
|
|
import $ from 'jquery';
|
2018-01-29 09:29:08 -05:00
|
|
|
import MockAdaptor from 'axios-mock-adapter';
|
|
|
|
import axios from '~/lib/utils/axios_utils';
|
2017-10-26 16:02:57 -04:00
|
|
|
import IssuableIndex from '~/issuable_index';
|
2019-07-09 07:46:16 -04:00
|
|
|
import issuableInitBulkUpdateSidebar from '~/issuable_init_bulk_update_sidebar';
|
2017-10-26 16:02:57 -04:00
|
|
|
|
|
|
|
describe('Issuable', () => {
|
|
|
|
describe('initBulkUpdate', () => {
|
|
|
|
it('should not set bulkUpdateSidebar', () => {
|
2019-07-09 07:46:16 -04:00
|
|
|
new IssuableIndex('issue_'); // eslint-disable-line no-new
|
2018-10-09 14:03:09 -04:00
|
|
|
|
2019-07-09 07:46:16 -04:00
|
|
|
expect(issuableInitBulkUpdateSidebar.bulkUpdateSidebar).toBeNull();
|
2016-12-15 10:07:41 -05:00
|
|
|
});
|
|
|
|
|
2017-10-26 16:02:57 -04:00
|
|
|
it('should set bulkUpdateSidebar', () => {
|
|
|
|
const element = document.createElement('div');
|
|
|
|
element.classList.add('issues-bulk-update');
|
|
|
|
document.body.appendChild(element);
|
2016-12-15 10:07:41 -05:00
|
|
|
|
2019-07-09 07:46:16 -04:00
|
|
|
new IssuableIndex('issue_'); // eslint-disable-line no-new
|
2018-10-09 14:03:09 -04:00
|
|
|
|
2019-07-09 07:46:16 -04:00
|
|
|
expect(issuableInitBulkUpdateSidebar.bulkUpdateSidebar).toBeDefined();
|
2016-12-15 10:07:41 -05:00
|
|
|
});
|
2017-10-26 16:02:57 -04:00
|
|
|
});
|
2016-12-15 10:07:41 -05:00
|
|
|
|
2017-10-26 16:02:57 -04:00
|
|
|
describe('resetIncomingEmailToken', () => {
|
2018-01-29 09:29:08 -05:00
|
|
|
let mock;
|
|
|
|
|
2017-10-26 16:02:57 -04:00
|
|
|
beforeEach(() => {
|
|
|
|
const element = document.createElement('a');
|
|
|
|
element.classList.add('incoming-email-token-reset');
|
|
|
|
element.setAttribute('href', 'foo');
|
|
|
|
document.body.appendChild(element);
|
2016-12-15 10:07:41 -05:00
|
|
|
|
2017-10-26 16:02:57 -04:00
|
|
|
const input = document.createElement('input');
|
2017-08-24 02:20:36 -04:00
|
|
|
input.setAttribute('id', 'issuable_email');
|
2017-10-26 16:02:57 -04:00
|
|
|
document.body.appendChild(input);
|
2016-12-15 10:07:41 -05:00
|
|
|
|
2019-07-09 07:46:16 -04:00
|
|
|
new IssuableIndex('issue_'); // eslint-disable-line no-new
|
2018-01-29 09:29:08 -05:00
|
|
|
|
|
|
|
mock = new MockAdaptor(axios);
|
|
|
|
|
|
|
|
mock.onPut('foo').reply(200, {
|
|
|
|
new_address: 'testing123',
|
|
|
|
});
|
2017-10-26 16:02:57 -04:00
|
|
|
});
|
2016-12-15 10:07:41 -05:00
|
|
|
|
2018-01-29 09:29:08 -05:00
|
|
|
afterEach(() => {
|
|
|
|
mock.restore();
|
|
|
|
});
|
|
|
|
|
2018-10-17 03:13:26 -04:00
|
|
|
it('should send request to reset email token', done => {
|
2018-01-29 09:29:08 -05:00
|
|
|
spyOn(axios, 'put').and.callThrough();
|
2017-10-26 16:02:57 -04:00
|
|
|
document.querySelector('.incoming-email-token-reset').click();
|
2016-12-15 10:07:41 -05:00
|
|
|
|
2018-01-29 09:29:08 -05:00
|
|
|
setTimeout(() => {
|
|
|
|
expect(axios.put).toHaveBeenCalledWith('foo');
|
|
|
|
expect($('#issuable_email').val()).toBe('testing123');
|
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
2016-12-15 10:07:41 -05:00
|
|
|
});
|
|
|
|
});
|
2017-10-26 16:02:57 -04:00
|
|
|
});
|