Skip to content

Commit 8ed51b8

Browse files
author
Said Shah
committed
Added tests for toast manager
1 parent c315cbc commit 8ed51b8

1 file changed

Lines changed: 46 additions & 1 deletion

File tree

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,48 @@
1+
import faker from "faker";
2+
import { ToastManager } from "./toast-manager";
3+
14
describe("ToastManager", () => {
2-
test.skip("TODO: Backfill tests for issue https://github.com/AndcultureCode/AndcultureCode.JavaScript.React.Components/issues/34", () => {});
5+
test("when error toast created, returns toastId", () => {
6+
// Arrange & Act
7+
const testToastId = faker.random.number(99);
8+
const toastContent = faker.random.word();
9+
const toastOptions = { toastId: testToastId };
10+
const toastId = ToastManager.error(toastContent, toastOptions);
11+
12+
// Act
13+
expect(toastId).toBe(testToastId);
14+
});
15+
16+
test("when info toast created, returns toastId", () => {
17+
// Arrange & Act
18+
const testToastId = faker.random.number(99);
19+
const toastContent = faker.random.word();
20+
const toastOptions = { toastId: testToastId };
21+
const toastId = ToastManager.info(toastContent, toastOptions);
22+
23+
// Act
24+
expect(toastId).toBe(testToastId);
25+
});
26+
27+
test("when success toast created, returns toastId", () => {
28+
// Arrange & Act
29+
const testToastId = faker.random.number(99);
30+
const toastContent = faker.random.word();
31+
const toastOptions = { toastId: testToastId };
32+
const toastId = ToastManager.success(toastContent, toastOptions);
33+
34+
// Act
35+
expect(toastId).toBe(testToastId);
36+
});
37+
38+
test("when warn toast created, returns toastId", () => {
39+
// Arrange & Act
40+
const testToastId = faker.random.number(99);
41+
const toastContent = faker.random.word();
42+
const toastOptions = { toastId: testToastId };
43+
const toastId = ToastManager.warn(toastContent, toastOptions);
44+
45+
// Act
46+
expect(toastId).toBe(testToastId);
47+
});
348
});

0 commit comments

Comments
 (0)