forked from eatvio/eatvio_app
feat(test): oauth, prefs, credentials
This commit is contained in:
62
test/features/auth/models/credentials_model_test.dart
Normal file
62
test/features/auth/models/credentials_model_test.dart
Normal file
@@ -0,0 +1,62 @@
|
||||
import 'package:eatvio_app/features/auth/models/credentials_model.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import '../../../fixtures/fixture_reader.dart';
|
||||
|
||||
void main() {
|
||||
group('CredentialsModel', () {
|
||||
late Map<String, dynamic> credentialsFixture;
|
||||
|
||||
setUp(() {
|
||||
credentialsFixture = FixtureReader.readAsMap('auth/login_credentials.json');
|
||||
});
|
||||
|
||||
test('создание модели из JSON', () {
|
||||
final model = CredentialsModel.fromJson(credentialsFixture);
|
||||
|
||||
expect(model.email, credentialsFixture['email']);
|
||||
expect(model.password, credentialsFixture['password']);
|
||||
});
|
||||
|
||||
test('создание модели через конструктор', () {
|
||||
const model = CredentialsModel(
|
||||
email: 'test@example.com',
|
||||
password: 'password123',
|
||||
);
|
||||
|
||||
expect(model.email, 'test@example.com');
|
||||
expect(model.password, 'password123');
|
||||
});
|
||||
|
||||
test('преобразование модели в JSON', () {
|
||||
const model = CredentialsModel(
|
||||
email: 'test@example.com',
|
||||
password: 'password123',
|
||||
);
|
||||
|
||||
final json = model.toJson();
|
||||
|
||||
expect(json['email'], 'test@example.com');
|
||||
expect(json['password'], 'password123');
|
||||
});
|
||||
|
||||
test('равенство моделей', () {
|
||||
const model1 = CredentialsModel(
|
||||
email: 'test@example.com',
|
||||
password: 'password123',
|
||||
);
|
||||
const model2 = CredentialsModel(
|
||||
email: 'test@example.com',
|
||||
password: 'password123',
|
||||
);
|
||||
const model3 = CredentialsModel(
|
||||
email: 'other@example.com',
|
||||
password: 'password123',
|
||||
);
|
||||
|
||||
expect(model1, equals(model2));
|
||||
expect(model1, isNot(equals(model3)));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user