blob: 0bf2737fb2bf97435dc76bb255b507f24e1bdb8e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
import toast from '~/vue_shared/plugins/global_toast';
const mockSpy = jest.fn();
jest.mock('@gitlab/ui', () => ({
GlToast: (Vue) => {
// eslint-disable-next-line no-param-reassign
Vue.prototype.$toast = { show: (...args) => mockSpy(...args) };
},
}));
describe('Global toast', () => {
afterEach(() => {
mockSpy.mockRestore();
});
it("should call GitLab UI's toast method", () => {
const arg1 = 'TestMessage';
const arg2 = { className: 'foo' };
toast(arg1, arg2);
expect(mockSpy).toHaveBeenCalledTimes(1);
expect(mockSpy).toHaveBeenCalledWith(arg1, arg2);
});
});
|