Add global toast module
**Why?** https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/15015#note_210891978
This commit is contained in:
parent
95d16dc007
commit
250660ca2d
2 changed files with 32 additions and 0 deletions
|
@ -0,0 +1,8 @@
|
|||
import Vue from 'vue';
|
||||
import { GlToast } from '@gitlab/ui';
|
||||
|
||||
Vue.use(GlToast);
|
||||
|
||||
export default function showGlobalToast(...args) {
|
||||
return Vue.toasted.show(...args);
|
||||
}
|
24
spec/frontend/vue_shared/plugins/global_toast_spec.js
Normal file
24
spec/frontend/vue_shared/plugins/global_toast_spec.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
import toast from '~/vue_shared/plugins/global_toast';
|
||||
import Vue from 'vue';
|
||||
|
||||
describe('Global toast', () => {
|
||||
let spyFunc;
|
||||
|
||||
beforeEach(() => {
|
||||
spyFunc = jest.spyOn(Vue.toasted, 'show').mockImplementation(() => {});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
spyFunc.mockRestore();
|
||||
});
|
||||
|
||||
it('should pass all args to Vue toasted', () => {
|
||||
const arg1 = 'TestMessage';
|
||||
const arg2 = { className: 'foo' };
|
||||
|
||||
toast(arg1, arg2);
|
||||
|
||||
expect(Vue.toasted.show).toHaveBeenCalledTimes(1);
|
||||
expect(Vue.toasted.show).toHaveBeenCalledWith(arg1, arg2);
|
||||
});
|
||||
});
|
Loading…
Reference in a new issue