@@ -3,46 +3,90 @@ import { ToastManager } from "./toast-manager";
33
44describe ( "ToastManager" , ( ) => {
55 test ( "when error toast created, returns toastId" , ( ) => {
6- // Arrange & Act
6+ // Arrange
77 const testToastId = faker . random . number ( 99 ) ;
88 const toastContent = faker . random . word ( ) ;
99 const toastOptions = { toastId : testToastId } ;
10- const toastId = ToastManager . error ( toastContent , toastOptions ) ;
1110
1211 // Act
12+ const toastId = ToastManager . error ( toastContent , toastOptions ) ;
13+
14+ // Assert
1315 expect ( toastId ) . toBe ( testToastId ) ;
1416 } ) ;
1517
1618 test ( "when info toast created, returns toastId" , ( ) => {
17- // Arrange & Act
19+ // Arrange
1820 const testToastId = faker . random . number ( 99 ) ;
1921 const toastContent = faker . random . word ( ) ;
2022 const toastOptions = { toastId : testToastId } ;
21- const toastId = ToastManager . info ( toastContent , toastOptions ) ;
2223
2324 // Act
25+ const toastId = ToastManager . info ( toastContent , toastOptions ) ;
26+
27+ // Assert
2428 expect ( toastId ) . toBe ( testToastId ) ;
2529 } ) ;
2630
2731 test ( "when success toast created, returns toastId" , ( ) => {
28- // Arrange & Act
32+ // Arrange
2933 const testToastId = faker . random . number ( 99 ) ;
3034 const toastContent = faker . random . word ( ) ;
3135 const toastOptions = { toastId : testToastId } ;
32- const toastId = ToastManager . success ( toastContent , toastOptions ) ;
3336
3437 // Act
38+ const toastId = ToastManager . success ( toastContent , toastOptions ) ;
39+
40+ // Assert
3541 expect ( toastId ) . toBe ( testToastId ) ;
3642 } ) ;
3743
3844 test ( "when warn toast created, returns toastId" , ( ) => {
39- // Arrange & Act
45+ // Arrange
4046 const testToastId = faker . random . number ( 99 ) ;
4147 const toastContent = faker . random . word ( ) ;
4248 const toastOptions = { toastId : testToastId } ;
43- const toastId = ToastManager . warn ( toastContent , toastOptions ) ;
4449
4550 // Act
51+ const toastId = ToastManager . warn ( toastContent , toastOptions ) ;
52+
53+ // Assert
4654 expect ( toastId ) . toBe ( testToastId ) ;
4755 } ) ;
56+
57+ test ( "when toast dismissed, calls dismiss method" , ( ) => {
58+ // Arrange
59+ const testId = faker . random . number ( 99 ) ;
60+ const dismissSpy = jest . spyOn ( ToastManager , "dismiss" ) ;
61+
62+ // Act
63+ ToastManager . dismiss ( testId ) ;
64+
65+ // Assert
66+ expect ( dismissSpy ) . toHaveBeenCalled ( ) ;
67+ } ) ;
68+
69+ test ( "when dismiss All toasts, calls dismissAll method" , ( ) => {
70+ // Arrange
71+ const dismissSpy = jest . spyOn ( ToastManager , "dismissAll" ) ;
72+
73+ // Act
74+ ToastManager . dismissAll ( ) ;
75+
76+ // Assert
77+ expect ( dismissSpy ) . toHaveBeenCalled ( ) ;
78+ } ) ;
79+
80+ test ( "when update toast, calls update method" , ( ) => {
81+ // Arrange
82+ const dismissSpy = jest . spyOn ( ToastManager , "update" ) ;
83+ const newContent = faker . random . words ( ) ;
84+ const testId = faker . random . number ( 99 ) ;
85+
86+ // Act
87+ ToastManager . update ( testId , newContent ) ;
88+
89+ // Assert
90+ expect ( dismissSpy ) . toHaveBeenCalled ( ) ;
91+ } ) ;
4892} ) ;
0 commit comments