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

24 lines
566 B
JavaScript
Raw Normal View History

2021-09-30 23:02:18 +05:30
import toast, { instance } from '~/vue_shared/plugins/global_toast';
2019-12-04 20:38:33 +05:30
describe('Global toast', () => {
let spyFunc;
beforeEach(() => {
2021-09-30 23:02:18 +05:30
spyFunc = jest.spyOn(instance.$toast, 'show').mockImplementation(() => {});
2019-12-04 20:38:33 +05:30
});
afterEach(() => {
spyFunc.mockRestore();
});
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);
2021-09-30 23:02:18 +05:30
expect(instance.$toast.show).toHaveBeenCalledTimes(1);
expect(instance.$toast.show).toHaveBeenCalledWith(arg1, arg2);
2019-12-04 20:38:33 +05:30
});
});