Commit 062547ce authored by Paul Gascou-Vaillancourt's avatar Paul Gascou-Vaillancourt Committed by Kushal Pandya

Use GitLab UI toast in global_toast

parent 9514d151
......@@ -2,7 +2,8 @@ import Vue from 'vue';
import { GlToast } from '@gitlab/ui';
Vue.use(GlToast);
const instance = new Vue();
export default function showGlobalToast(...args) {
return Vue.toasted.show(...args);
return instance.$toast.show(...args);
}
import toast from '~/vue_shared/plugins/global_toast';
import Vue from 'vue';
import toast from '~/vue_shared/plugins/global_toast';
describe('Global toast', () => {
let spyFunc;
beforeEach(() => {
spyFunc = jest.spyOn(Vue.toasted, 'show').mockImplementation(() => {});
spyFunc = jest.spyOn(Vue.prototype.$toast, 'show').mockImplementation(() => {});
});
afterEach(() => {
spyFunc.mockRestore();
});
it('should pass all args to Vue toasted', () => {
it("should call GitLab UI's toast method", () => {
const arg1 = 'TestMessage';
const arg2 = { className: 'foo' };
toast(arg1, arg2);
expect(Vue.toasted.show).toHaveBeenCalledTimes(1);
expect(Vue.toasted.show).toHaveBeenCalledWith(arg1, arg2);
expect(Vue.prototype.$toast.show).toHaveBeenCalledTimes(1);
expect(Vue.prototype.$toast.show).toHaveBeenCalledWith(arg1, arg2);
});
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment