Skip to content

Commit 88edd4b

Browse files
committed
test: update auth success response tests
- Use CheckedFromJsonException - Improve error type checking
1 parent 18511a4 commit 88edd4b

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

test/src/models/responses/auth_success_response_test.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'package:ht_shared/ht_shared.dart';
2+
import 'package:json_annotation/json_annotation.dart';
23
import 'package:test/test.dart';
34

45
void main() {
@@ -41,14 +42,14 @@ void main() {
4142
final jsonMissingUser = {'token': testToken};
4243
expect(
4344
() => AuthSuccessResponse.fromJson(jsonMissingUser),
44-
throwsA(isA<TypeError>()), // Or specific JsonKeyRequiredError
45+
throwsA(isA<CheckedFromJsonException>()),
4546
);
4647

4748
// Missing 'token'
4849
final jsonMissingToken = {'user': testUser.toJson()};
4950
expect(
5051
() => AuthSuccessResponse.fromJson(jsonMissingToken),
51-
throwsA(isA<TypeError>()), // Or specific JsonKeyRequiredError
52+
throwsA(isA<CheckedFromJsonException>()),
5253
);
5354
});
5455

@@ -60,7 +61,7 @@ void main() {
6061
};
6162
expect(
6263
() => AuthSuccessResponse.fromJson(jsonWrongUserType),
63-
throwsA(isA<TypeError>()),
64+
throwsA(isA<CheckedFromJsonException>()),
6465
);
6566

6667
// Incorrect type for 'token'
@@ -70,7 +71,7 @@ void main() {
7071
};
7172
expect(
7273
() => AuthSuccessResponse.fromJson(jsonWrongTokenType),
73-
throwsA(isA<TypeError>()),
74+
throwsA(isA<CheckedFromJsonException>()),
7475
);
7576
});
7677
});

0 commit comments

Comments
 (0)