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

25 lines
590 B
JavaScript
Raw Normal View History

2019-12-04 20:38:33 +05:30
import Vue from 'vue';
2019-12-21 20:55:43 +05:30
import toast from '~/vue_shared/plugins/global_toast';
2019-12-04 20:38:33 +05:30
describe('Global toast', () => {
let spyFunc;
beforeEach(() => {
2019-12-21 20:55:43 +05:30
spyFunc = jest.spyOn(Vue.prototype.$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);
2019-12-21 20:55:43 +05:30
expect(Vue.prototype.$toast.show).toHaveBeenCalledTimes(1);
expect(Vue.prototype.$toast.show).toHaveBeenCalledWith(arg1, arg2);
2019-12-04 20:38:33 +05:30
});
});