Tests for actions
This commit is contained in:
parent
56caf37263
commit
af68bedfb3
1 changed files with 37 additions and 0 deletions
37
src/app-bridge/actions.test.ts
Normal file
37
src/app-bridge/actions.test.ts
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
import { describe, expect, it } from "vitest";
|
||||||
|
|
||||||
|
import { actions, NotificationPayload, RedirectPayload } from "./actions";
|
||||||
|
|
||||||
|
describe("actions.ts", () => {
|
||||||
|
describe("actions.Notification", () => {
|
||||||
|
it("Constructs action with \"notification\" type, random id and payload", () => {
|
||||||
|
const payload: NotificationPayload = {
|
||||||
|
apiMessage: "test-api-message",
|
||||||
|
status: "info",
|
||||||
|
text: "test-text",
|
||||||
|
title: "test-title",
|
||||||
|
};
|
||||||
|
|
||||||
|
const action = actions.Notification(payload);
|
||||||
|
|
||||||
|
expect(action.type).toBe("notification");
|
||||||
|
expect(action.payload.actionId).toEqual(expect.any(String));
|
||||||
|
expect(action.payload).toEqual(expect.objectContaining(payload));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("actions.Redirect", () => {
|
||||||
|
it("Constructs action with \"redirect\" type, random id and payload", () => {
|
||||||
|
const payload: RedirectPayload = {
|
||||||
|
newContext: true,
|
||||||
|
to: "/foo/bar",
|
||||||
|
};
|
||||||
|
|
||||||
|
const action = actions.Redirect(payload);
|
||||||
|
|
||||||
|
expect(action.type).toBe("redirect");
|
||||||
|
expect(action.payload.actionId).toEqual(expect.any(String));
|
||||||
|
expect(action.payload).toEqual(expect.objectContaining(payload));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in a new issue