package Ġcom . br ais gab in . show med am oney . presentation . contacts Ċ Ċ import Ġarrow . core . Either Ċ import Ġcom . br ais gab in . show med am oney . contact Ċ import Ġorg . hamcrest . Core Matchers .` is ` Ċ import Ġorg . hamcrest . Matcher Assert . assertThat Ċ import Ġorg . junit . Test Ċ Ċ class ĠRetrieve Data Partial State Test Ġ{ ĊĠ Ġprivate Ġvar Ġsubject Ġ= ĠRetrieve Data Partial State ( Either . right ( listOf ( contact ( id Ġ= Ġ" 1 "), Ġcontact ( id Ġ= Ġ" 2 ")) )) ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` retrieve Ġdata Ġwith Ġprogress `() Ġ{ ĊĠĠĠ ĠassertThat ( subject ( Contacts State . Progress ), Ġ` is `( Contacts State . Data ( listOf ( ĊĠĠĠĠĠĠĠ ĠSelected Contact ( contact (" 1 "), Ġfalse ), ĊĠĠĠĠĠĠĠ ĠSelected Contact ( contact (" 2 "), Ġfalse )), Ġfalse ) Ġas ĠContact s State )) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` retrieve Ġdata Ġwith Ġretry `() Ġ{ ĊĠĠĠ ĠassertThat ( subject ( Contacts State . Retry ), Ġ` is `( Contacts State . Data ( listOf ( ĊĠĠĠĠĠĠĠ ĠSelected Contact ( contact (" 1 "), Ġfalse ), ĊĠĠĠĠĠĠĠ ĠSelected Contact ( contact (" 2 "), Ġfalse )), Ġfalse ) Ġas ĠContact s State )) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` retrieve Ġdata Ġwith Ġdata `() Ġ{ ĊĠĠĠ ĠassertThat ( subject ( Contacts State . Data ( emptyList (), Ġfalse )), Ġ` is `( Contacts State . Data ( listOf ( ĊĠĠĠĠĠĠĠ ĠSelected Contact ( contact (" 1 "), Ġfalse ), ĊĠĠĠĠĠĠĠ ĠSelected Contact ( contact (" 2 "), Ġfalse )), Ġfalse ) Ġas ĠContact s State )) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` retrieve Ġerror Ġwith Ġprogress `() Ġ{ ĊĠĠĠ Ġsubject Ġ= ĠRetrieve Data Partial State ( Either . left ( Exception ())) ĊĠĠĠ ĠassertThat ( subject ( Contacts State . Progress ), Ġ` is `( Contacts State . Retry Ġas ĠContact s State )) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` retrieve Ġerror Ġwith Ġretry `() Ġ{ ĊĠĠĠ Ġsubject Ġ= ĠRetrieve Data Partial State ( Either . left ( Exception ())) ĊĠĠĠ ĠassertThat ( subject ( Contacts State . Retry ), Ġ` is `( Contacts State . Retry Ġas ĠContact s State )) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` retrieve Ġerror Ġwith Ġdata `() Ġ{ ĊĠĠĠ Ġsubject Ġ= ĠRetrieve Data Partial State ( Either . left ( Exception ())) ĊĠĠĠ ĠassertThat ( subject ( Contacts State . Data ( emptyList (), Ġfalse )), Ġ` is `( Contacts State . Retry Ġas ĠContact s State )) ĊĠ Ġ} Ċ } Ċ Ċ class ĠClick Contact Partial State Test Ġ{ ĊĠ Ġprivate Ġvar Ġsubject Ġ= ĠClick Contact Partial State ( Selected Contact ( contact ( id Ġ= Ġ" 1 "), Ġfalse )) ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` if Ġwe Ġcall Ġwith ĠProgress Ġwe Ġget Ġthe Ġsame `() Ġ{ ĊĠĠĠ ĠassertThat ( subject ( Contacts State . Progress ), Ġ` is `( Contacts State . Progress Ġas ĠContact s State )) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` if Ġwe Ġcall Ġwith ĠRetry Ġwe Ġget Ġthe Ġsame `() Ġ{ ĊĠĠĠ ĠassertThat ( subject ( Contacts State . Retry ), Ġ` is `( Contacts State . Retry Ġas ĠContact s State )) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` if Ġwe Ġcall Ġwith ĠData Ġthe Ġselection Ġchanges Ġpositive `() Ġ{ ĊĠĠĠ Ġval Ġdata Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠ ĠSelected Contact ( contact (" 1 "), Ġfalse ), ĊĠĠĠĠĠĠĠ ĠSelected Contact ( contact (" 2 "), Ġfalse )) ĊĠĠĠ Ġval Ġdata 2 Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠ ĠSelected Contact ( contact (" 1 "), Ġtrue ), ĊĠĠĠĠĠĠĠ ĠSelected Contact ( contact (" 2 "), Ġfalse )) ĊĠĠĠ ĠassertThat ( subject ( Contacts State . Data ( data , Ġfalse )), Ġ` is `( Contacts State . Data ( data 2 , Ġtrue ) Ġas ĠContact s State )) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` if Ġwe Ġcall Ġwith ĠData Ġthe Ġselection Ġchanges Ġnegative `() Ġ{ ĊĠĠĠ Ġsubject Ġ= ĠClick Contact Partial State ( Selected Contact ( contact ( id Ġ= Ġ" 1 "), Ġtrue )) ĊĠĠĠ Ġval Ġdata Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠ ĠSelected Contact ( contact (" 1 "), Ġtrue ), ĊĠĠĠĠĠĠĠ ĠSelected Contact ( contact (" 2 "), Ġfalse )) ĊĠĠĠ Ġval Ġdata 2 Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠ ĠSelected Contact ( contact (" 1 "), Ġfalse ), ĊĠĠĠĠĠĠĠ ĠSelected Contact ( contact (" 2 "), Ġfalse )) ĊĠĠĠ ĠassertThat ( subject ( Contacts State . Data ( data , Ġtrue )), Ġ` is `( Contacts State . Data ( data 2 , Ġfalse ) Ġas ĠContact s State )) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` if Ġwe Ġcall Ġwith ĠData Ġthe Ġselection Ġchanges Ġat Ġleast Ġone Ġselected `() Ġ{ ĊĠĠĠ Ġsubject Ġ= ĠClick Contact Partial State ( Selected Contact ( contact ( id Ġ= Ġ" 1 "), Ġtrue )) ĊĠĠĠ Ġval Ġdata Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠ ĠSelected Contact ( contact (" 1 "), Ġtrue ), ĊĠĠĠĠĠĠĠ ĠSelected Contact ( contact (" 2 "), Ġtrue )) ĊĠĠĠ Ġval Ġdata 2 Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠ ĠSelected Contact ( contact (" 1 "), Ġfalse ), ĊĠĠĠĠĠĠĠ ĠSelected Contact ( contact (" 2 "), Ġtrue )) ĊĠĠĠ ĠassertThat ( subject ( Contacts State . Data ( data , Ġtrue )), Ġ` is `( Contacts State . Data ( data 2 , Ġtrue ) Ġas ĠContact s State )) ĊĠ Ġ} Ċ } Ċ Ċ class ĠIdentity Test Ġ{ ĊĠ Ġprivate Ġval Ġsubject Ġ= ĠIdentity < String >() ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` assert Ġidentity `() Ġ{ ĊĠĠĠ ĠassertThat ( subject (" 1 "), Ġ` is ` (" 1 ")) ĊĠĠĠ ĠassertThat ( subject (" 2 "), Ġ` is ` (" 2 ")) ĊĠ Ġ} Ċ } ĊĊ