2019-09-10 21:20:20 +00:00
|
|
|
import Vue from 'vue';
|
2019-09-23 09:06:22 +00:00
|
|
|
import toast from '~/vue_shared/plugins/global_toast';
|
2019-09-10 21:20:20 +00:00
|
|
|
|
|
|
|
describe('Global toast', () => {
|
|
|
|
let spyFunc;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
2019-09-23 09:06:22 +00:00
|
|
|
spyFunc = jest.spyOn(Vue.prototype.$toast, 'show').mockImplementation(() => {});
|
2019-09-10 21:20:20 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
spyFunc.mockRestore();
|
|
|
|
});
|
|
|
|
|
2019-09-23 09:06:22 +00:00
|
|
|
it("should call GitLab UI's toast method", () => {
|
2019-09-10 21:20:20 +00:00
|
|
|
const arg1 = 'TestMessage';
|
|
|
|
const arg2 = { className: 'foo' };
|
|
|
|
|
|
|
|
toast(arg1, arg2);
|
|
|
|
|
2019-09-23 09:06:22 +00:00
|
|
|
expect(Vue.prototype.$toast.show).toHaveBeenCalledTimes(1);
|
|
|
|
expect(Vue.prototype.$toast.show).toHaveBeenCalledWith(arg1, arg2);
|
2019-09-10 21:20:20 +00:00
|
|
|
});
|
|
|
|
});
|