Skip to content

Commit

Permalink
toast tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberhorsey committed Dec 9, 2022
1 parent 7fc14e2 commit 843e76d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions packages/bridge-ui/src/utils/toast.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,23 @@ const mockPush = jest.fn();

jest.mock("@zerodevx/svelte-toast", () => ({
...(jest.requireActual("@zerodevx/svelte-toast") as object),
push: mockPush,
toast: {
push: mockPush,
},
}));

import { successToast, errorToast } from "./toast";
import { successToast, errorToast, successOpts, errorOpts } from "./toast";
describe("toasts", function () {
beforeEach(() => {
jest.resetAllMocks();
});
it("should call successToast with msg and opts", () => {
successToast("msg");
expect(mockPush).toHaveBeenCalledWith("msg", {});
expect(mockPush).toHaveBeenCalledWith("msg", successOpts);
});

it("should call errorToast with msg and opts", () => {
errorToast("msg");
expect(mockPush).toHaveBeenCalledWith("msg", {});
expect(mockPush).toHaveBeenCalledWith("msg", errorOpts);
});
});
4 changes: 2 additions & 2 deletions packages/bridge-ui/src/utils/toast.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { toast } from "@zerodevx/svelte-toast";
import type { SvelteToastOptions } from "@zerodevx/svelte-toast";

const errorOpts: SvelteToastOptions = {
export const errorOpts: SvelteToastOptions = {
theme: {
"--toastBackground": "#FF0000",
"--toastColor": "#e3e3e3",
Expand All @@ -14,7 +14,7 @@ const errorOpts: SvelteToastOptions = {
},
};

const successOpts: SvelteToastOptions = {
export const successOpts: SvelteToastOptions = {
theme: {
"--toastBackground": "#008000",
"--toastColor": "#e3e3e3",
Expand Down

0 comments on commit 843e76d

Please sign in to comment.