summaryrefslogtreecommitdiff
path: root/spec/frontend/vue_shared/plugins/global_toast_spec.js
blob: 551abe3cb415b53fddc719f1459c84c413a14e9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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);
  });
});