feat(tests): test coverage is 70.5

This commit is contained in:
misha
2026-01-26 16:38:15 +03:00
parent 92205c09d6
commit 29589ef6fd
49 changed files with 2690 additions and 18 deletions

View File

@@ -146,5 +146,87 @@ void main() {
expect(json['weight'], 70);
expect(json['height'], 180);
});
test('copyWith creates new instance with updated values', () {
const original = OAuthVerificationConfirmRequest(
accessToken: 'access_token_123',
refreshToken: 'refresh_token_123',
clientId: 'client_id_123',
provider: 'vk',
id: 'user_id_123',
code: 'code_123',
verificationType: 'email',
firstName: 'John',
lastName: 'Doe',
dateOfBirth: '1990-01-01',
gender: 'male',
weight: 70,
height: 180,
);
final updated = original.copyWith(firstName: 'Jane', weight: 65);
expect(updated.firstName, 'Jane');
expect(updated.weight, 65);
expect(original.firstName, 'John');
expect(original.weight, 70);
});
test('copyWith keeps original values when not updated', () {
const original = OAuthVerificationConfirmRequest(
accessToken: 'access_token_123',
refreshToken: 'refresh_token_123',
clientId: 'client_id_123',
provider: 'vk',
id: 'user_id_123',
code: 'code_123',
verificationType: 'email',
firstName: 'John',
lastName: 'Doe',
dateOfBirth: '1990-01-01',
gender: 'male',
weight: 70,
height: 180,
);
final updated = original.copyWith();
expect(updated.accessToken, original.accessToken);
expect(updated.firstName, original.firstName);
});
test('handles different providers', () {
const vkRequest = OAuthVerificationConfirmRequest(
accessToken: 'token',
refreshToken: 'refresh',
clientId: 'client',
provider: 'vk',
id: 'id',
code: 'code',
verificationType: 'email',
firstName: 'John',
lastName: 'Doe',
dateOfBirth: '1990-01-01',
gender: 'male',
weight: 70,
height: 180,
);
const googleRequest = OAuthVerificationConfirmRequest(
accessToken: 'token',
refreshToken: 'refresh',
clientId: 'client',
provider: 'google',
id: 'id',
code: 'code',
verificationType: 'email',
firstName: 'John',
lastName: 'Doe',
dateOfBirth: '1990-01-01',
gender: 'male',
weight: 70,
height: 180,
);
expect(vkRequest.provider, 'vk');
expect(googleRequest.provider, 'google');
});
});
}

View File

@@ -93,5 +93,60 @@ void main() {
expect(response1, equals(response2));
expect(response1, isNot(equals(response3)));
});
test('copyWith creates new instance with updated values', () {
const original = OAuthVerificationConfirmResponse(
success: true,
message: 'Success',
token: 'token_123',
user: {'id': 1, 'name': 'John'},
isNewUser: false,
);
final updated = original.copyWith(success: false, message: 'Error', isNewUser: true);
expect(updated.success, false);
expect(updated.message, 'Error');
expect(updated.isNewUser, true);
expect(original.success, true);
expect(original.isNewUser, false);
});
test('copyWith keeps original values when not updated', () {
const original = OAuthVerificationConfirmResponse(
success: true,
message: 'Success',
token: 'token_123',
user: {'id': 1, 'name': 'John'},
isNewUser: false,
);
final updated = original.copyWith();
expect(updated.success, original.success);
expect(updated.message, original.message);
expect(updated.token, original.token);
expect(updated.user, original.user);
expect(updated.isNewUser, original.isNewUser);
});
test('handles different user data', () {
const response1 = OAuthVerificationConfirmResponse(
success: true,
message: 'Success',
token: 'token_123',
user: {'id': 1, 'name': 'John'},
isNewUser: false,
);
const response2 = OAuthVerificationConfirmResponse(
success: true,
message: 'Success',
token: 'token_123',
user: {'id': 2, 'name': 'Jane', 'email': 'jane@example.com'},
isNewUser: true,
);
expect(response1.user['id'], 1);
expect(response2.user['id'], 2);
expect(response2.user['email'], 'jane@example.com');
});
});
}

View File

@@ -13,28 +13,23 @@ void main() {
expect(response.status, 'pending');
});
test('fromJson creates instance from JSON', () {
final json = {
'email': 'test@example.com',
'status': 'pending',
};
final response = OAuthVerificationRequestResponse.fromJson(json);
expect(response.email, 'test@example.com');
expect(response.status, 'pending');
});
test('toJson converts instance to JSON', () {
const response = OAuthVerificationRequestResponse(
test('creates instance with different status values', () {
const pending = OAuthVerificationRequestResponse(
email: 'test@example.com',
status: 'pending',
);
const completed = OAuthVerificationRequestResponse(
email: 'test@example.com',
status: 'completed',
);
const failed = OAuthVerificationRequestResponse(
email: 'test@example.com',
status: 'failed',
);
final json = response.toJson();
expect(json['email'], 'test@example.com');
expect(json['status'], 'pending');
expect(pending.status, 'pending');
expect(completed.status, 'completed');
expect(failed.status, 'failed');
});
test('equality works correctly', () {
@@ -54,5 +49,28 @@ void main() {
expect(response1, equals(response2));
expect(response1, isNot(equals(response3)));
});
test('copyWith creates new instance with updated values', () {
const original = OAuthVerificationRequestResponse(
email: 'test@example.com',
status: 'pending',
);
final updated = original.copyWith(status: 'completed');
expect(updated.email, 'test@example.com');
expect(updated.status, 'completed');
expect(original.status, 'pending');
});
test('copyWith keeps original values when not updated', () {
const original = OAuthVerificationRequestResponse(
email: 'test@example.com',
status: 'pending',
);
final updated = original.copyWith();
expect(updated.email, original.email);
expect(updated.status, original.status);
});
});
}