Skip to content

Commit 40c82b0

Browse files
committed
style: misc
1 parent 95bc173 commit 40c82b0

File tree

3 files changed

+15
-53
lines changed

3 files changed

+15
-53
lines changed

lib/src/models/user.dart

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,10 @@ part 'user.g.dart';
1111
class User extends Equatable {
1212
/// Creates a new [User] instance.
1313
///
14-
/// Requires a unique [id] and a [role].
15-
/// The [email] is optional and typically present only for users
16-
/// who have verified their email address.
17-
const User({
18-
required this.id,
19-
required this.role,
20-
this.email,
21-
});
14+
/// Requires a unique [id] and a [role].
15+
/// The [email] is optional and typically present only for users
16+
/// who have verified their email address.
17+
const User({required this.id, required this.role, this.email});
2218

2319
/// Creates a User from JSON data.
2420
factory User.fromJson(Map<String, dynamic> json) => _$UserFromJson(json);

test/src/models/auth_success_response_test.dart

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,7 @@ void main() {
115115
});
116116

117117
test('should create a copy with both user and token updated', () {
118-
const updatedUser = User(
119-
id: 'user-789',
120-
role: 'guest_user',
121-
);
118+
const updatedUser = User(id: 'user-789', role: 'guest_user');
122119
const updatedToken = 'another-token-xyz';
123120
final copiedResponse = authSuccessResponse.copyWith(
124121
user: updatedUser,
@@ -140,10 +137,7 @@ void main() {
140137
});
141138

142139
test('should not equate instances with different users', () {
143-
const differentUser = User(
144-
id: 'diff-user',
145-
role: 'admin',
146-
);
140+
const differentUser = User(id: 'diff-user', role: 'admin');
147141
const response1 = AuthSuccessResponse(user: testUser, token: testToken);
148142
const response2 = AuthSuccessResponse(
149143
user: differentUser,

test/src/models/user_test.dart

Lines changed: 9 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,13 @@ void main() {
99
test('supports value equality', () {
1010
expect(
1111
const User(id: id, email: email, role: 'standard_user'),
12-
equals(
13-
const User(id: id, email: email, role: 'standard_user'),
14-
),
12+
equals(const User(id: id, email: email, role: 'standard_user')),
1513
);
1614
expect(
1715
const User(id: id, email: email, role: 'standard_user'),
1816
isNot(
1917
equals(
20-
const User(
21-
id: 'other-id',
22-
email: email,
23-
role: 'standard_user',
24-
),
18+
const User(id: 'other-id', email: email, role: 'standard_user'),
2519
),
2620
),
2721
);
@@ -39,32 +33,18 @@ void main() {
3933
);
4034
expect(
4135
const User(id: id, email: email, role: 'standard_user'),
42-
isNot(
43-
equals(
44-
const User(id: id, email: email, role: 'guest_user'),
45-
),
46-
),
36+
isNot(equals(const User(id: id, email: email, role: 'guest_user'))),
4737
);
48-
expect(
38+
expect(
4939
const User(id: id, email: email, role: 'standard_user'),
50-
isNot(
51-
equals(
52-
const User(id: id, email: email, role: 'admin'),
53-
),
54-
),
40+
isNot(equals(const User(id: id, email: email, role: 'admin'))),
5541
);
5642
});
5743

5844
test('has correct toString', () {
5945
expect(
60-
const User(
61-
id: id,
62-
email: email,
63-
role: 'standard_user',
64-
).toString(),
65-
equals(
66-
'User(id: $id, email: $email, role: standard_user)',
67-
),
46+
const User(id: id, email: email, role: 'standard_user').toString(),
47+
equals('User(id: $id, email: $email, role: standard_user)'),
6848
);
6949
expect(
7050
const User(id: id, role: 'guest_user').toString(),
@@ -78,11 +58,7 @@ void main() {
7858

7959
// Basic test for JSON serialization - assumes build_runner generated correctly
8060
test('can be serialized and deserialized', () {
81-
const user = User(
82-
id: id,
83-
email: email,
84-
role: 'standard_user',
85-
);
61+
const user = User(id: id, email: email, role: 'standard_user');
8662
final json = user.toJson();
8763
final deserializedUser = User.fromJson(json);
8864
expect(deserializedUser, equals(user));
@@ -92,11 +68,7 @@ void main() {
9268
final deserializedAnonUser = User.fromJson(anonJson);
9369
expect(deserializedAnonUser, equals(anonUser));
9470

95-
const adminUser = User(
96-
id: id,
97-
email: email,
98-
role: 'admin',
99-
);
71+
const adminUser = User(id: id, email: email, role: 'admin');
10072
final adminJson = adminUser.toJson();
10173
final deserializedAdminUser = User.fromJson(adminJson);
10274
expect(deserializedAdminUser, equals(adminUser));

0 commit comments

Comments
 (0)