Commit f165bda4 authored by Phil Hughes's avatar Phil Hughes

fixed failing specs

parent 58eb3c55
......@@ -246,7 +246,7 @@ export default class MergeRequestTabs {
return;
}
this.toggleLoading(true)
this.toggleLoading(true);
axios.get(`${source}.json`)
.then(({ data }) => {
......
/* eslint-disable space-before-function-paren, one-var, one-var-declaration-per-line, no-use-before-define, comma-dangle, max-len */
import MockAdaptor from 'axios-mock-adapter';
import MockAdapter from 'axios-mock-adapter';
import axios from '~/lib/utils/axios_utils';
import Issue from '~/issue';
import '~/lib/utils/text_utility';
......@@ -138,7 +138,7 @@ describe('Issue', function() {
this.issueStateDeferred = new jQuery.Deferred();
this.canCreateBranchDeferred = new jQuery.Deferred();
mock = new MockAdaptor(axios);
mock = new MockAdapter(axios);
spyOn(jQuery, 'ajax').and.callFake(ajaxSpy.bind(this));
});
......
import MockAdaptor from 'axios-mock-adapter';
import MockAdapter from 'axios-mock-adapter';
import axios from '~/lib/utils/axios_utils';
import { numberToHumanSize } from '~/lib/utils/number_utils';
import * as urlUtils from '~/lib/utils/url_utility';
......@@ -22,11 +22,9 @@ describe('Job', () => {
spyOn(urlUtils, 'visitUrl');
mock = new MockAdaptor(axios);
mock = new MockAdapter(axios);
mock.onGet(new RegExp(`${JOB_URL}/trace.json?(.*)`)).reply(() => {
return [200, response];
});
mock.onGet(new RegExp(`${JOB_URL}/trace.json?(.*)`)).reply(() => [200, response]);
});
afterEach(() => {
......
/* eslint-disable no-new */
import MockAdapter from 'axios-mock-adapter';
import axios from '~/lib/utils/axios_utils';
import IssuableContext from '~/issuable_context';
import LabelsSelect from '~/labels_select';
......@@ -10,35 +12,44 @@ import '~/users_select';
(() => {
let saveLabelCount = 0;
let mock;
describe('Issue dropdown sidebar', () => {
preloadFixtures('static/issue_sidebar_label.html.raw');
beforeEach(() => {
loadFixtures('static/issue_sidebar_label.html.raw');
mock = new MockAdapter(axios);
new IssuableContext('{"id":1,"name":"Administrator","username":"root"}');
new LabelsSelect();
spyOn(jQuery, 'ajax').and.callFake((req) => {
const d = $.Deferred();
let LABELS_DATA = [];
mock.onGet('/root/test/labels.json').reply(() => {
const labels = Array(10).fill().map((_, i) => ({
id: i,
title: `test ${i}`,
color: '#5CB85C',
}));
if (req.url === '/root/test/labels.json') {
for (let i = 0; i < 10; i += 1) {
LABELS_DATA.push({ id: i, title: `test ${i}`, color: '#5CB85C' });
}
} else if (req.url === '/root/test/issues/2.json') {
const tmp = [];
for (let i = 0; i < saveLabelCount; i += 1) {
tmp.push({ id: i, title: `test ${i}`, color: '#5CB85C' });
}
LABELS_DATA = { labels: tmp };
}
return [200, labels];
});
mock.onPut('/root/test/issues/2.json').reply(() => {
const labels = Array(saveLabelCount).fill().map((_, i) => ({
id: i,
title: `test ${i}`,
color: '#5CB85C',
}));
d.resolve(LABELS_DATA);
return d.promise();
return [200, { labels }];
});
});
afterEach(() => {
mock.restore();
});
it('changes collapsed tooltip when changing labels when less than 5', (done) => {
saveLabelCount = 5;
$('.edit-link').get(0).click();
......
/* eslint-disable no-var, comma-dangle, object-shorthand */
import MockAdaptor from 'axios-mock-adapter';
import MockAdapter from 'axios-mock-adapter';
import axios from '~/lib/utils/axios_utils';
import * as urlUtils from '~/lib/utils/url_utility';
import MergeRequestTabs from '~/merge_request_tabs';
......@@ -218,7 +218,7 @@ import 'vendor/jquery.scrollTo';
let mock;
beforeEach(function () {
mock = new MockAdaptor(axios);
mock = new MockAdapter(axios);
mock.onGet(/(.*)\/diffs\.json/).reply(200, {
data: { html: '' },
});
......@@ -344,7 +344,7 @@ import 'vendor/jquery.scrollTo';
.attr('href')
.replace('#', '');
mock = new MockAdaptor(axios);
mock = new MockAdapter(axios);
mock.onGet(/(.*)\/diffs\.json/).reply(200, diffsResponse);
});
......@@ -410,7 +410,7 @@ import 'vendor/jquery.scrollTo';
.attr('href')
.replace('#', '');
mock = new MockAdaptor(axios);
mock = new MockAdapter(axios);
mock.onGet(/(.*)\/diffs\.json/).reply(200, diffsResponse);
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment