Commit 822b1b3b authored by Phil Hughes's avatar Phil Hughes

fixed karma specs with change to axios instead of $.ajax

parent 6a7527c9
/* global BoardService */ /* global BoardService */
import Vue from 'vue'; import Vue from 'vue';
import MockAdapter from 'axios-mock-adapter';
import axios from '~/lib/utils/axios_utils';
import '~/labels_select'; import '~/labels_select';
import LabelsSelect from '~/boards/components/labels_select.vue'; import LabelsSelect from '~/boards/components/labels_select.vue';
import IssuableContext from '~/issuable_context'; import IssuableContext from '~/issuable_context';
...@@ -32,14 +34,16 @@ const label2 = { ...@@ -32,14 +34,16 @@ const label2 = {
}; };
describe('LabelsSelect', () => { describe('LabelsSelect', () => {
let mock;
beforeEach((done) => { beforeEach((done) => {
setFixtures('<div class="test-container"></div>'); setFixtures('<div class="test-container"></div>');
const deferred = new jQuery.Deferred(); mock = new MockAdapter(axios);
spyOn($, 'ajax').and.returnValue(deferred.resolve([ mock.onGet('/some/path').reply(200, [
label, label,
label2, label2,
])); ]);
// eslint-disable-next-line no-new // eslint-disable-next-line no-new
new IssuableContext(); new IssuableContext();
...@@ -60,6 +64,10 @@ describe('LabelsSelect', () => { ...@@ -60,6 +64,10 @@ describe('LabelsSelect', () => {
Vue.nextTick(done); Vue.nextTick(done);
}); });
afterEach(() => {
mock.restore();
});
describe('canEdit', () => { describe('canEdit', () => {
it('hides Edit button', (done) => { it('hides Edit button', (done) => {
vm.canEdit = false; vm.canEdit = false;
......
/* global BoardService */ /* global BoardService */
import Vue from 'vue'; import Vue from 'vue';
import MockAdapater from 'axios-mock-adapter';
import axios from '~/lib/utils/axios_utils';
import MilestoneSelect from '~/boards/components/milestone_select.vue'; import MilestoneSelect from '~/boards/components/milestone_select.vue';
import IssuableContext from '~/issuable_context'; import IssuableContext from '~/issuable_context';
import { boardObj } from './mock_data'; import { boardObj } from './mock_data';
...@@ -92,12 +94,18 @@ describe('Milestone select component', () => { ...@@ -92,12 +94,18 @@ describe('Milestone select component', () => {
}); });
describe('clicking dropdown items', () => { describe('clicking dropdown items', () => {
let mock;
beforeEach(() => { beforeEach(() => {
const deferred = new jQuery.Deferred(); mock = new MockAdapater(axios);
spyOn($, 'ajax').and.returnValue(deferred.resolve([ mock.onGet('/test/issue-boards/milestones.json').reply(200, [
milestone, milestone,
milestone2, milestone2,
])); ]);
});
afterEach(() => {
mock.restore();
}); });
it('sets Any Milestone', (done) => { it('sets Any Milestone', (done) => {
......
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