-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: data/models coverage %100 OK - +128 ~12: All tests passed!
- Loading branch information
Showing
15 changed files
with
5,444 additions
and
88 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,91 @@ | ||
import 'dart:convert'; | ||
|
||
import 'package:flutter_bloc_advance/data/models/change_password.dart'; | ||
import 'package:flutter_bloc_advance/main/main_local.mapper.g.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
import '../../fake/user_data.dart'; | ||
|
||
/// Test the Change Password model | ||
void main() { | ||
var model = mockPasswordChangePayload; | ||
|
||
setUp(() { | ||
initializeJsonMapper(); | ||
}); | ||
|
||
group("Change Password Model", () { | ||
test('should create a ChangePassword instance (Constructor)', () { | ||
expect(model.currentPassword, 'password'); | ||
expect(model.newPassword, 'new_password'); | ||
expect(mockPasswordChangePayload.currentPassword, 'password'); | ||
expect(mockPasswordChangePayload.newPassword, 'new_password'); | ||
}); | ||
|
||
test('should copy a ChangePassword instance with new values (copyWith)', () { | ||
final updatedChangePassword = model.copyWith( | ||
final updatedChangePassword = mockPasswordChangePayload.copyWith( | ||
currentPassword: 'new_password', | ||
newPassword: 'password', | ||
); | ||
|
||
expect(updatedChangePassword.currentPassword, 'new_password'); | ||
expect(updatedChangePassword.newPassword, 'password'); | ||
}); | ||
|
||
test('should copy a ChangePassword instance with new values (copyWith)', () { | ||
final updatedChangePassword = mockPasswordChangePayload.copyWith(); | ||
expect(updatedChangePassword == mockPasswordChangePayload, true); | ||
}); | ||
|
||
test('should compare two ChangePassword instances', () { | ||
final updatedChangePassword = model.copyWith( | ||
final updatedChangePassword = mockPasswordChangePayload.copyWith( | ||
currentPassword: 'new_password', | ||
newPassword: 'password', | ||
); | ||
|
||
expect(model == updatedChangePassword, false); | ||
expect(mockPasswordChangePayload == updatedChangePassword, false); | ||
}); | ||
}); | ||
|
||
//fromJson, fromJsonString, toJson, props, toString | ||
group("Change Password Model Json Test", () { | ||
test('should convert ChangePassword from Json', () { | ||
final json = mockPasswordChangePayload.toJson(); | ||
|
||
final changePassword = PasswordChangeDTO.fromJson(json!); | ||
|
||
expect(changePassword?.currentPassword, 'password'); | ||
expect(changePassword?.newPassword, 'new_password'); | ||
}); | ||
|
||
test('should convert ChangePassword from JsonString', () { | ||
final jsonString = jsonEncode(mockPasswordChangePayload.toJson()); | ||
|
||
final changePassword = PasswordChangeDTO.fromJsonString(jsonString); | ||
|
||
expect(changePassword?.currentPassword, 'password'); | ||
expect(changePassword?.newPassword, 'new_password'); | ||
}); | ||
|
||
test('should convert ChangePassword to Json', () { | ||
final json = mockPasswordChangePayload.toJson()!; | ||
expect(json['currentPassword'], 'password'); | ||
expect(json['newPassword'], 'new_password'); | ||
}); | ||
|
||
test('should compare two ChangePassword instances props', () { | ||
final updatedChangePassword = mockPasswordChangePayload.copyWith( | ||
currentPassword: 'new_password', | ||
newPassword: 'password', | ||
); | ||
|
||
expect(mockPasswordChangePayload.props == updatedChangePassword.props, false); | ||
}); | ||
|
||
test('should compare two ChangePassword instances toString', () { | ||
final updatedChangePassword = mockPasswordChangePayload.copyWith( | ||
currentPassword: 'new_password', | ||
newPassword: 'password', | ||
); | ||
|
||
expect(mockPasswordChangePayload.toString() == updatedChangePassword.toString(), false); | ||
}); | ||
}); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,14 @@ void main() { | |
test('should copy a Customer instance with new values (copyWith)', () { | ||
final finalCustomer = customerMockFullPayload; | ||
|
||
final updatedCustomer = finalCustomer.copyWith(); | ||
|
||
expect(updatedCustomer == finalCustomer, true); | ||
}); | ||
|
||
test('should copy a Customer instance with new values (copyWith) new values', () { | ||
final finalCustomer = customerMockFullPayload; | ||
|
||
final updatedCustomer = finalCustomer.copyWith( | ||
name: 'new Acme', | ||
cityName: 'izmir', | ||
|
@@ -74,5 +82,20 @@ void main() { | |
expect(finalCustomer?.address, 'yazır mh.'); | ||
expect(finalCustomer?.active, true); | ||
}); | ||
|
||
//props | ||
test('props test', () { | ||
final finalCustomer = customerMockFullPayload; | ||
final updatedCustomer = finalCustomer.copyWith(); | ||
|
||
expect(finalCustomer.props, updatedCustomer.props); | ||
}); | ||
|
||
//toString | ||
test('should return string', () { | ||
final finalCustomer = customerMockFullPayload; | ||
expect(finalCustomer.toString(), | ||
'Customer(1, Acme, 5055055050, [email protected], Konya, selçuklu, yazır mh., true)'); | ||
}); | ||
}); | ||
} |
Oops, something went wrong.