1- import { addHandlers , ChooseOptions , ConfirmOptions , ConfirmService , Handlers , Option , removeHandlers } from "../src/Service" ;
1+ import { addHandlers , AlertOptions , ChooseOptions , ConfirmOptions , ConfirmService , Handlers , Option , removeHandlers } from "../src/Service" ;
22
33describe ( "Service" , ( ) => {
44 const mockAlert = jest . fn ( ) ;
@@ -19,7 +19,8 @@ describe("Service", () => {
1919 } ) ;
2020
2121 describe ( "alert" , ( ) => {
22- it ( "calls the provided alert function" , ( ) => {
22+ it ( "calls the provided alert function with a severity" , ( ) => {
23+ // arrange
2324 const message = "Message" ;
2425 const severity = "error" ;
2526
@@ -31,6 +32,22 @@ describe("Service", () => {
3132 expect ( mockAlert ) . toHaveBeenCalledWith ( message , severity ) ;
3233 } ) ;
3334
35+ it ( "calls the provided alert function with an options object" , ( ) => {
36+ // arrange
37+ const message = "Message" ;
38+ const options : AlertOptions = {
39+ severity : "error" ,
40+ duration : 1000 ,
41+ } ;
42+
43+ // act
44+ ConfirmService . alert ( message , options ) ;
45+
46+ // assert
47+ expect ( alert . alert ) . toHaveBeenCalledTimes ( 1 ) ;
48+ expect ( mockAlert ) . toHaveBeenCalledWith ( message , options ) ;
49+ } ) ;
50+
3451 it ( "throws if not initialized" , ( ) => {
3552 // arrange
3653 removeHandlers ( alert ) ;
0 commit comments