summaryrefslogtreecommitdiff
path: root/spec/frontend/vue_shared/plugins/global_toast_spec.js
blob: 322586a772c9b258a2a19684d3d7bdc59e80bc3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import toast, { instance } from '~/vue_shared/plugins/global_toast';

describe('Global toast', () => {
  let spyFunc;

  beforeEach(() => {
    spyFunc = jest.spyOn(instance.$toast, 'show').mockImplementation(() => {});
  });

  afterEach(() => {
    spyFunc.mockRestore();
  });

  it("should call GitLab UI's toast method", () => {
    const arg1 = 'TestMessage';
    const arg2 = { className: 'foo' };

    toast(arg1, arg2);

    expect(instance.$toast.show).toHaveBeenCalledTimes(1);
    expect(instance.$toast.show).toHaveBeenCalledWith(arg1, arg2);
  });
});