2018-05-09 12:01:36 +05:30
|
|
|
import $ from 'jquery';
|
2018-03-17 18:26:18 +05:30
|
|
|
import MockAdaptor from 'axios-mock-adapter';
|
|
|
|
import axios from '~/lib/utils/axios_utils';
|
|
|
|
import IssuableIndex from '~/issuable_index';
|
|
|
|
|
|
|
|
describe('Issuable', () => {
|
|
|
|
let Issuable;
|
|
|
|
describe('initBulkUpdate', () => {
|
|
|
|
it('should not set bulkUpdateSidebar', () => {
|
|
|
|
Issuable = new IssuableIndex('issue_');
|
|
|
|
expect(Issuable.bulkUpdateSidebar).not.toBeDefined();
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
it('should set bulkUpdateSidebar', () => {
|
|
|
|
const element = document.createElement('div');
|
|
|
|
element.classList.add('issues-bulk-update');
|
|
|
|
document.body.appendChild(element);
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
Issuable = new IssuableIndex('issue_');
|
|
|
|
expect(Issuable.bulkUpdateSidebar).toBeDefined();
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
describe('resetIncomingEmailToken', () => {
|
|
|
|
let mock;
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
beforeEach(() => {
|
|
|
|
const element = document.createElement('a');
|
|
|
|
element.classList.add('incoming-email-token-reset');
|
|
|
|
element.setAttribute('href', 'foo');
|
|
|
|
document.body.appendChild(element);
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
const input = document.createElement('input');
|
|
|
|
input.setAttribute('id', 'issuable_email');
|
|
|
|
document.body.appendChild(input);
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
Issuable = new IssuableIndex('issue_');
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
mock = new MockAdaptor(axios);
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
mock.onPut('foo').reply(200, {
|
|
|
|
new_address: 'testing123',
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
afterEach(() => {
|
|
|
|
mock.restore();
|
|
|
|
});
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
it('should send request to reset email token', (done) => {
|
|
|
|
spyOn(axios, 'put').and.callThrough();
|
|
|
|
document.querySelector('.incoming-email-token-reset').click();
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
setTimeout(() => {
|
|
|
|
expect(axios.put).toHaveBeenCalledWith('foo');
|
|
|
|
expect($('#issuable_email').val()).toBe('testing123');
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
done();
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
|
|
|
|