debian-mirror-gitlab/spec/frontend/vue_shared/plugins/global_toast_spec.js
2023-05-27 22:25:52 +05:30

25 lines
613 B
JavaScript

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);
});
});