@@ -107,26 +107,26 @@ void main() {
107107 // Test with specific email and token values from the issue
108108 const testOtp = '329169' ;
109109 const specificEmail
= '[email protected] ' ;
110-
110+
111111 // Create a custom mock client that verifies the request body
112112 final verifyingMockClient = VerifyingOtpMockClient (
113113 expectedEmail: specificEmail,
114114 expectedToken: testOtp,
115115 );
116-
116+
117117 final verifyingClient = GoTrueClient (
118118 url: 'https://example.com' ,
119119 httpClient: verifyingMockClient,
120120 asyncStorage: asyncStorage,
121121 );
122-
122+
123123 // This should succeed if parameters are sent correctly
124124 await verifyingClient.verifyOTP (
125125 email: specificEmail,
126126 token: testOtp,
127127 type: OtpType .email,
128128 );
129-
129+
130130 // Test passes if no exceptions were thrown
131131 expect (verifyingMockClient.requestWasValid, isTrue);
132132 });
@@ -649,34 +649,31 @@ class VerifyingOtpMockClient extends BaseClient {
649649 Future <StreamedResponse > send (BaseRequest request) async {
650650 if (request.url.toString ().contains ('/verify' ) && request is Request ) {
651651 final requestBody = json.decode (request.body) as Map <String , dynamic >;
652-
652+
653653 // Verify that email parameter maps to 'email' field
654654 if (requestBody['email' ] != expectedEmail) {
655655 throw Exception (
656- 'Expected email "$expectedEmail " in request body "email" field, '
657- 'but got "${requestBody ['email' ]}"'
658- );
656+ 'Expected email "$expectedEmail " in request body "email" field, '
657+ 'but got "${requestBody ['email' ]}"' );
659658 }
660-
659+
661660 // Verify that token parameter maps to 'token' field
662661 if (requestBody['token' ] != expectedToken) {
663662 throw Exception (
664- 'Expected token "$expectedToken " in request body "token" field, '
665- 'but got "${requestBody ['token' ]}"'
666- );
663+ 'Expected token "$expectedToken " in request body "token" field, '
664+ 'but got "${requestBody ['token' ]}"' );
667665 }
668-
666+
669667 // Verify parameters are not swapped
670- if (requestBody['email' ] == expectedToken || requestBody['token' ] == expectedEmail) {
671- throw Exception (
672- 'Parameters appear to be swapped! '
673- 'email field contains: "${requestBody ['email' ]}", '
674- 'token field contains: "${requestBody ['token' ]}"'
675- );
668+ if (requestBody['email' ] == expectedToken ||
669+ requestBody['token' ] == expectedEmail) {
670+ throw Exception ('Parameters appear to be swapped! '
671+ 'email field contains: "${requestBody ['email' ]}", '
672+ 'token field contains: "${requestBody ['token' ]}"' );
676673 }
677-
674+
678675 requestWasValid = true ;
679-
676+
680677 // Return a valid response
681678 final now = DateTime .now ().toIso8601String ();
682679 return StreamedResponse (
@@ -707,7 +704,7 @@ class VerifyingOtpMockClient extends BaseClient {
707704 request: request,
708705 );
709706 }
710-
707+
711708 return StreamedResponse (
712709 Stream .value (utf8.encode (jsonEncode ({'error' : 'Unhandled request' }))),
713710 404 ,
0 commit comments