@@ -43,29 +43,40 @@ describe("Element focus", () => {
4343 const input = document . body . appendChild ( document . createElement ( "input" ) ) ;
4444
4545 const machine = start ( ButtonFocusListener . bind ( null , button ) ) ;
46-
47- expect ( machine . current ) . toEqual ( "Inactive" ) ;
48- expect ( machine . changeCount ) . toEqual ( 0 ) ;
46+ expect ( machine . value ) . toMatchObject ( {
47+ change : 0 ,
48+ state : "Inactive" ,
49+ } ) ;
4950
5051 button . focus ( ) ;
51- expect ( machine . current ) . toEqual ( "Active" ) ;
52- expect ( machine . changeCount ) . toEqual ( 2 ) ;
52+ expect ( machine . value ) . toMatchObject ( {
53+ change : 2 ,
54+ state : "Active" ,
55+ } ) ;
5356
5457 button . focus ( ) ;
55- expect ( machine . current ) . toEqual ( "Active" ) ;
56- expect ( machine . changeCount ) . toEqual ( 2 ) ;
58+ expect ( machine . value ) . toMatchObject ( {
59+ change : 2 ,
60+ state : "Active" ,
61+ } ) ;
5762
5863 input . focus ( ) ;
59- expect ( machine . current ) . toEqual ( "Inactive" ) ;
60- expect ( machine . changeCount ) . toEqual ( 4 ) ;
64+ expect ( machine . value ) . toMatchObject ( {
65+ change : 4 ,
66+ state : "Inactive" ,
67+ } ) ;
6168
6269 button . focus ( ) ;
63- expect ( machine . current ) . toEqual ( "Active" ) ;
64- expect ( machine . changeCount ) . toEqual ( 6 ) ;
70+ expect ( machine . value ) . toMatchObject ( {
71+ change : 6 ,
72+ state : "Active" ,
73+ } ) ;
6574
6675 button . blur ( ) ;
67- expect ( machine . current ) . toEqual ( "Inactive" ) ;
68- expect ( machine . changeCount ) . toEqual ( 8 ) ;
76+ expect ( machine . value ) . toMatchObject ( {
77+ change : 8 ,
78+ state : "Inactive" ,
79+ } ) ;
6980
7081 machine . abort ( ) ;
7182 button . remove ( ) ;
@@ -77,9 +88,10 @@ describe("Element focus", () => {
7788
7889 button . focus ( ) ;
7990 const machine = start ( ButtonFocusListener . bind ( null , button ) ) ;
80-
81- expect ( machine . current ) . toEqual ( "Active" ) ;
82- expect ( machine . changeCount ) . toEqual ( 0 ) ;
91+ expect ( machine . value ) . toMatchObject ( {
92+ change : 0 ,
93+ state : "Active" ,
94+ } ) ;
8395
8496 button . remove ( ) ;
8597 machine . abort ( ) ;
@@ -105,6 +117,7 @@ describe("Textbox validation", () => {
105117 function * CheckingValid ( ) {
106118 yield cond ( el . value === '' , InvalidCannotBeEmpty ) ;
107119 yield cond ( / ^ [ a - z ] + $ / . test ( el . value ) === false , InvalidMustBeLowercase ) ;
120+ // yield cond(false)(/^[a-z]+$/.test(el.value), InvalidMustBeLowercase);
108121 yield always ( Valid ) ;
109122 }
110123
@@ -115,29 +128,40 @@ describe("Textbox validation", () => {
115128 const input = document . body . appendChild ( document . createElement ( "input" ) ) ;
116129
117130 const machine = start ( RequiredInputValidationResponder . bind ( null , input ) ) ;
118-
119- expect ( machine . current ) . toEqual ( "Inactive" ) ;
120- expect ( machine . changeCount ) . toEqual ( 0 ) ;
131+ expect ( machine . value ) . toMatchObject ( {
132+ change : 0 ,
133+ state : "Inactive" ,
134+ } ) ;
121135
122136 user . click ( input ) ;
123- expect ( machine . current ) . toEqual ( "Active" ) ;
124- expect ( machine . changeCount ) . toEqual ( 2 ) ;
137+ expect ( machine . value ) . toMatchObject ( {
138+ change : 2 ,
139+ state : "Active" ,
140+ } ) ;
125141
126142 user . click ( document . body ) ;
127- expect ( machine . current ) . toEqual ( "Inactive" ) ;
128- expect ( machine . changeCount ) . toEqual ( 4 ) ;
143+ expect ( machine . value ) . toMatchObject ( {
144+ change : 4 ,
145+ state : "Inactive" ,
146+ } ) ;
129147
130- user . type ( input , "hello" ) ;
131- expect ( machine . current ) . toEqual ( "Valid" ) ;
148+ user . paste ( input , "hello" ) ;
149+ expect ( machine . value ) . toMatchObject ( {
150+ change : 8 ,
151+ state : "Valid" ,
152+ } ) ;
132153
133154 user . clear ( input ) ;
134- expect ( machine . current ) . toEqual ( "InvalidCannotBeEmpty" ) ;
155+ expect ( machine . value ) . toMatchObject ( {
156+ change : 10 ,
157+ state : "InvalidCannotBeEmpty" ,
158+ } ) ;
135159
136- user . type ( input , "HELLO" ) ;
137- expect ( machine . current ) . toEqual ( "InvalidMustBeLowercase" ) ;
138-
139- user . type ( input , "lowercase" ) ;
140- expect ( machine . current ) . toEqual ( "InvalidMustBeLowercase" ) ;
160+ user . paste ( input , "HELLO" ) ;
161+ expect ( machine . value ) . toMatchObject ( {
162+ change : 12 ,
163+ state : "InvalidMustBeLowercase" ,
164+ } ) ;
141165
142166 input . remove ( ) ;
143167 machine . abort ( ) ;
0 commit comments