11import { render , RenderResult , waitFor } from "@testing-library/react" ;
22import { useEffect } from "react" ;
3- import { Cmd , createCmd , SubscriptionResult , UpdateReturnType , useElmish } from "../src" ;
3+ import { Cmd , createCmd , InitResult , SubscriptionResult , UpdateReturnType , useElmish } from "../src" ;
44
55type Message =
66 | { name : "Test" }
@@ -14,12 +14,12 @@ interface Model {
1414}
1515
1616interface Props {
17- init : ( ) => [ Model , Cmd < Message > ] ,
17+ init : ( ) => InitResult < Model , Message > ,
1818 update : ( model : Model , msg : Message , props : Props ) => UpdateReturnType < Model , Message > ,
1919 subscription ?: ( model : Model ) => SubscriptionResult < Message > ,
2020}
2121
22- function defaultInit ( msg : Cmd < Message > ) : [ Model , Cmd < Message > ] {
22+ function defaultInit ( msg ? : Cmd < Message > ) : InitResult < Model , Message > {
2323 return [
2424 {
2525 value1 : "" ,
@@ -100,7 +100,7 @@ describe("useElmish", () => {
100100 it ( "updates the model correctly with multiple commands delayed" , async ( ) => {
101101 // arrange
102102 const props : Props = {
103- init : ( ) => defaultInit ( cmd . none ) ,
103+ init : ( ) => defaultInit ( ) ,
104104 update ( _model : Model , msg : Message ) : UpdateReturnType < Model , Message > {
105105 // eslint-disable-next-line jest/no-conditional-in-test
106106 switch ( msg . name ) {
@@ -134,7 +134,7 @@ describe("useElmish", () => {
134134 // arrange
135135 const mockSub = jest . fn ( ) ;
136136 const mockSubscription = jest . fn ( ) . mockReturnValue ( [ cmd . ofSub ( mockSub ) ] ) ;
137- const [ initModel , initCmd ] = defaultInit ( cmd . none ) ;
137+ const [ initModel , initCmd ] = defaultInit ( ) ;
138138 const props : Props = {
139139 init : ( ) => [ initModel , initCmd ] ,
140140 update : defaultUpdate ,
@@ -153,8 +153,8 @@ describe("useElmish", () => {
153153 it ( "calls the subscriptions destructor if provided" , ( ) => {
154154 // arrange
155155 const mockDestructor = jest . fn ( ) ;
156- const mockSubscription = jest . fn ( ) . mockReturnValue ( [ cmd . none , mockDestructor ] ) ;
157- const [ initModel , initCmd ] = defaultInit ( cmd . none ) ;
156+ const mockSubscription = jest . fn ( ) . mockReturnValue ( [ [ ] , mockDestructor ] ) ;
157+ const [ initModel , initCmd ] = defaultInit ( ) ;
158158 const props : Props = {
159159 init : ( ) => [ initModel , initCmd ] ,
160160 update : defaultUpdate ,
0 commit comments