Commit c16d5bcd authored by winniehell's avatar winniehell

Move Ajax interceptor into describe block (!7304)

parent 50f3fd49
......@@ -13,8 +13,9 @@
//= require boards/stores/boards_store
//= require ./mock_data
(() => {
describe('Store', () => {
beforeEach(() => {
Vue.http.interceptors.push(boardsMockInterceptor);
gl.boardService = new BoardService('/test/issue-boards/board', '1');
gl.issueBoards.BoardsStore.create();
......@@ -24,7 +25,10 @@
});
});
describe('Store', () => {
afterEach(() => {
Vue.http.interceptors = _.without(Vue.http.interceptors, boardsMockInterceptor);
});
it('starts with a blank state', () => {
expect(gl.issueBoards.BoardsStore.state.lists.length).toBe(0);
});
......@@ -164,5 +168,4 @@
}, 0);
});
});
});
})();
});
......@@ -17,12 +17,17 @@ describe('List model', () => {
let list;
beforeEach(() => {
Vue.http.interceptors.push(boardsMockInterceptor);
gl.boardService = new BoardService('/test/issue-boards/board', '1');
gl.issueBoards.BoardsStore.create();
list = new List(listObj);
});
afterEach(() => {
Vue.http.interceptors = _.without(Vue.http.interceptors, boardsMockInterceptor);
});
it('gets issues when created', (done) => {
setTimeout(() => {
expect(list.issues.length).toBe(1);
......
......@@ -48,10 +48,10 @@ const BoardsMockData = {
}
};
Vue.http.interceptors.push((request, next) => {
const boardsMockInterceptor = (request, next) => {
const body = BoardsMockData[request.method][request.url];
next(request.respondWith(JSON.stringify(body), {
status: 200
}));
});
};
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