Move Ajax interceptor into describe block (!7304)
This commit is contained in:
parent
50f3fd49a2
commit
c16d5bcd48
|
@ -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);
|
||||
});
|
||||
|
@ -165,4 +169,3 @@
|
|||
});
|
||||
});
|
||||
});
|
||||
})();
|
||||
|
|
|
@ -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
|
||||
}));
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue