2021-06-24 09:07:22 +00:00
|
|
|
import toast, { instance } from '~/vue_shared/plugins/global_toast';
|
2019-09-10 21:20:20 +00:00
|
|
|
|
|
|
|
describe('Global toast', () => {
|
|
|
|
let spyFunc;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
2021-06-24 09:07:22 +00:00
|
|
|
spyFunc = jest.spyOn(instance.$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);
|
|
|
|
|
2021-06-24 09:07:22 +00:00
|
|
|
expect(instance.$toast.show).toHaveBeenCalledTimes(1);
|
|
|
|
expect(instance.$toast.show).toHaveBeenCalledWith(arg1, arg2);
|
2019-09-10 21:20:20 +00:00
|
|
|
});
|
|
|
|
});
|