@@ -59,4 +59,109 @@ void main() {
59
59
expect (didSignIn, true );
60
60
});
61
61
});
62
+
63
+ group ('register' , () {
64
+ testWidgets ('''
65
+ Given formType is register
66
+ When tap on the sign-in button
67
+ Then createUserWithEmailAndPassword is not called
68
+ ''' , (tester) async {
69
+ final r = AuthRobot (tester);
70
+ await r.pumpEmailPasswordSignInContents (
71
+ authRepository: authRepository,
72
+ formType: EmailPasswordSignInFormType .register,
73
+ );
74
+ await r.tapEmailAndPasswordSubmitButton ();
75
+ verifyNever (() => authRepository.createUserWithEmailAndPassword (
76
+ any (),
77
+ any (),
78
+ ));
79
+ });
80
+ testWidgets ('''
81
+ Given formType is register
82
+ When enter valid email
83
+ And enter password that is too short
84
+ And tap on the sign-in button
85
+ Then createUserWithEmailAndPassword is called
86
+ And onSignedIn callback is called
87
+ And error alert is not shown
88
+ ''' , (tester) async {
89
+ final r = AuthRobot (tester);
90
+ when (() => authRepository.createUserWithEmailAndPassword (
91
+ testEmail,
92
+ testPassword,
93
+ )).thenAnswer ((_) => Future .value ());
94
+ await r.pumpEmailPasswordSignInContents (
95
+ authRepository: authRepository,
96
+ formType: EmailPasswordSignInFormType .register,
97
+ );
98
+ await r.enterEmail (testEmail);
99
+ await r.enterPassword (testPassword);
100
+ await r.tapEmailAndPasswordSubmitButton ();
101
+ verifyNever (() => authRepository.createUserWithEmailAndPassword (
102
+ any (),
103
+ any (),
104
+ ));
105
+ });
106
+ testWidgets ('''
107
+ Given formType is register
108
+ When enter valid email
109
+ And enter password that is long enough
110
+ And tap on the sign-in button
111
+ Then createUserWithEmailAndPassword is called
112
+ And onSignedIn callback is called
113
+ And error alert is not shown
114
+ ''' , (tester) async {
115
+ var didSignIn = false ;
116
+ final r = AuthRobot (tester);
117
+ const password = 'test1234' ; // at least 8 characters to pass validation
118
+ when (() => authRepository.createUserWithEmailAndPassword (
119
+ testEmail,
120
+ password,
121
+ )).thenAnswer ((_) => Future .value ());
122
+ await r.pumpEmailPasswordSignInContents (
123
+ authRepository: authRepository,
124
+ formType: EmailPasswordSignInFormType .register,
125
+ onSignedIn: () => didSignIn = true ,
126
+ );
127
+ await r.enterEmail (testEmail);
128
+ await r.enterPassword (password);
129
+ await r.tapEmailAndPasswordSubmitButton ();
130
+ verify (() => authRepository.createUserWithEmailAndPassword (
131
+ testEmail,
132
+ password,
133
+ )).called (1 );
134
+ r.expectErrorAlertNotFound ();
135
+ expect (didSignIn, true );
136
+ });
137
+ });
138
+
139
+ group ('updateFormType' , () {
140
+ testWidgets ('''
141
+ Given formType is sign in
142
+ When tap on the form toggle button
143
+ Then create account button is found
144
+ ''' , (tester) async {
145
+ final r = AuthRobot (tester);
146
+ await r.pumpEmailPasswordSignInContents (
147
+ authRepository: authRepository,
148
+ formType: EmailPasswordSignInFormType .signIn,
149
+ );
150
+ await r.tapFormToggleButton ();
151
+ r.expectCreateAccountButtonFound ();
152
+ });
153
+ testWidgets ('''
154
+ Given formType is sign in
155
+ When tap on the form toggle button
156
+ Then create account button is found
157
+ ''' , (tester) async {
158
+ final r = AuthRobot (tester);
159
+ await r.pumpEmailPasswordSignInContents (
160
+ authRepository: authRepository,
161
+ formType: EmailPasswordSignInFormType .register,
162
+ );
163
+ await r.tapFormToggleButton ();
164
+ r.expectCreateAccountButtonNotFound ();
165
+ });
166
+ });
62
167
}
0 commit comments