debian-mirror-gitlab/spec/frontend/vue_shared/plugins/global_toast_spec.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

26 lines
613 B
JavaScript
Raw Normal View History

2023-05-27 22:25:52 +05:30
import toast from '~/vue_shared/plugins/global_toast';
2019-12-04 20:38:33 +05:30
2023-05-27 22:25:52 +05:30
const mockSpy = jest.fn();
jest.mock('@gitlab/ui', () => ({
GlToast: (Vue) => {
// eslint-disable-next-line no-param-reassign
Vue.prototype.$toast = { show: (...args) => mockSpy(...args) };
},
}));
2019-12-04 20:38:33 +05:30
2023-05-27 22:25:52 +05:30
describe('Global toast', () => {
2019-12-04 20:38:33 +05:30
afterEach(() => {
2023-05-27 22:25:52 +05:30
mockSpy.mockRestore();
2019-12-04 20:38:33 +05:30
});
2019-12-21 20:55:43 +05:30
it("should call GitLab UI's toast method", () => {
2019-12-04 20:38:33 +05:30
const arg1 = 'TestMessage';
const arg2 = { className: 'foo' };
toast(arg1, arg2);
2023-05-27 22:25:52 +05:30
expect(mockSpy).toHaveBeenCalledTimes(1);
expect(mockSpy).toHaveBeenCalledWith(arg1, arg2);
2019-12-04 20:38:33 +05:30
});
});