@@ -10,14 +10,14 @@ describe('Form', () => {
1010 } ) ;
1111 const signInButton = getByText ( 'Sign in' ) ;
1212
13- expect ( component . form . $$ . ctx . $isSubmitting ) . toBe ( false ) ;
13+ expect ( component . form . $capture_state ( ) . $isSubmitting ) . toBe ( false ) ;
1414 expect ( signInButton ) . not . toHaveAttribute ( 'disabled' ) ;
1515
1616 await fireEvent . click ( signInButton ) ;
1717 await wait ( ) ;
1818 expect ( component . onSubmit ) . toHaveBeenCalledTimes ( 1 ) ;
1919 expect ( signInButton ) . toHaveAttribute ( 'disabled' ) ;
20- expect ( component . form . $$ . ctx . $isSubmitting ) . toBe ( true ) ;
20+ expect ( component . form . $capture_state ( ) . $isSubmitting ) . toBe ( true ) ;
2121 } ) ;
2222
2323 it ( 'onSubmit event returns values, resetForm, setSubmitting' , async done => {
@@ -32,17 +32,20 @@ describe('Form', () => {
3232 ( { detail : { values, setSubmitting, resetForm } } ) => {
3333 expect ( values ) . toMatchSnapshot ( ) ;
3434
35- expect ( component . form . $$ . ctx . $isSubmitting ) . toBeTruthy ( ) ;
35+ expect ( component . form . $capture_state ( ) . $isSubmitting ) . toBeTruthy ( ) ;
36+
3637 setSubmitting ( false ) ;
37- expect ( component . form . $$ . ctx . $isSubmitting ) . toBeFalsy ( ) ;
38+ let formState = component . form . $capture_state ( ) ;
39+ expect ( formState . $isSubmitting ) . toBeFalsy ( ) ;
40+ expect ( formState . $values ) . toMatchSnapshot ( ) ;
41+ expect ( formState . $errors ) . toMatchSnapshot ( ) ;
42+ expect ( formState . $touched ) . toMatchSnapshot ( ) ;
3843
39- expect ( component . form . $$ . ctx . $values ) . toMatchSnapshot ( ) ;
40- expect ( component . form . $$ . ctx . $errors ) . toMatchSnapshot ( ) ;
41- expect ( component . form . $$ . ctx . $touched ) . toMatchSnapshot ( ) ;
4244 resetForm ( ) ;
43- expect ( component . form . $$ . ctx . $values ) . toMatchSnapshot ( ) ;
44- expect ( component . form . $$ . ctx . $errors ) . toMatchSnapshot ( ) ;
45- expect ( component . form . $$ . ctx . $touched ) . toMatchSnapshot ( ) ;
45+ formState = component . form . $capture_state ( ) ;
46+ expect ( formState . $values ) . toMatchSnapshot ( ) ;
47+ expect ( formState . $errors ) . toMatchSnapshot ( ) ;
48+ expect ( formState . $touched ) . toMatchSnapshot ( ) ;
4649
4750 done ( ) ;
4851 }
@@ -68,7 +71,7 @@ describe('Form', () => {
6871
6972 const signInButton = getByText ( 'Sign in' ) ;
7073
71- expect ( component . form . $$ . ctx . $isSubmitting ) . toBe ( false ) ;
74+ expect ( component . form . $capture_state ( ) . $isSubmitting ) . toBe ( false ) ;
7275 expect ( signInButton ) . not . toHaveAttribute ( 'disabled' ) ;
7376
7477 await fireEvent . click ( signInButton ) ;
@@ -81,11 +84,11 @@ describe('Form', () => {
8184 user : { email : 'initial@value.com' } ,
8285 } ,
8386 onSubmit : jest . fn ( ( { detail : { resetForm } } ) => {
84- expect ( component . form . $$ . ctx . $values . user . email ) . toEqual (
87+ expect ( component . form . $capture_state ( ) . $values . user . email ) . toEqual (
8588 'test@user.com'
8689 ) ;
8790 resetForm ( ) ;
88- expect ( component . form . $$ . ctx . $values . user . email ) . toEqual (
91+ expect ( component . form . $capture_state ( ) . $values . user . email ) . toEqual (
8992 'initial@value.com'
9093 ) ;
9194
@@ -110,13 +113,13 @@ describe('Form', () => {
110113 user : { email : 'initial@value.com' } ,
111114 } ,
112115 onSubmit : jest . fn ( ( { detail : { resetForm } } ) => {
113- expect ( component . form . $$ . ctx . $values . user . email ) . toEqual (
116+ expect ( component . form . $capture_state ( ) . $values . user . email ) . toEqual (
114117 'test@user.com'
115118 ) ;
116119 resetForm ( {
117120 user : { email : 'after@reset.com' } ,
118121 } ) ;
119- expect ( component . form . $$ . ctx . $values . user . email ) . toEqual (
122+ expect ( component . form . $capture_state ( ) . $values . user . email ) . toEqual (
120123 'after@reset.com'
121124 ) ;
122125
@@ -160,7 +163,7 @@ describe('Form', () => {
160163 await wait ( ( ) => {
161164 expect ( getByText ( 'user.email must be a valid email' ) ) . toBeInTheDocument ( ) ;
162165 } ) ;
163- expect ( component . form . $$ . ctx . $errors ) . toEqual ( {
166+ expect ( component . form . $capture_state ( ) . $errors ) . toEqual ( {
164167 user : { email : 'user.email must be a valid email' } ,
165168 } ) ;
166169
@@ -170,12 +173,12 @@ describe('Form', () => {
170173 it ( 'registers fields and sets default values' , async ( ) => {
171174 const { component } = await render ( App ) ;
172175
173- expect ( component . form . $$ . ctx . $values ) . toMatchObject ( {
176+ expect ( component . form . $capture_state ( ) . $values ) . toMatchObject ( {
174177 user : { email : '' } ,
175178 language : '' ,
176179 os : [ ] ,
177180 } ) ;
178- expect ( component . form . $$ . ctx . $touched ) . toMatchObject ( {
181+ expect ( component . form . $capture_state ( ) . $touched ) . toMatchObject ( {
179182 user : { email : false } ,
180183 language : false ,
181184 os : false ,
@@ -184,15 +187,15 @@ describe('Form', () => {
184187
185188 it ( 'isValid is undefined initially' , async ( ) => {
186189 const { component } = await render ( App ) ;
187- expect ( component . form . $$ . ctx . isValid ) . toBe ( undefined ) ;
190+ expect ( component . form . $capture_state ( ) . isValid ) . toBe ( undefined ) ;
188191 } ) ;
189192
190193 it ( 'sets initial values' , async ( ) => {
191194 const { component } = await render ( App , {
192195 props : { initialValues : { user : { email : 'test@user.com' } } } ,
193196 } ) ;
194197
195- expect ( component . form . $$ . ctx . $values ) . toMatchObject ( {
198+ expect ( component . form . $capture_state ( ) . $values ) . toMatchObject ( {
196199 user : { email : 'test@user.com' } ,
197200 language : '' ,
198201 os : [ ] ,
0 commit comments