feat(test): oauth, prefs, credentials

This commit is contained in:
mso7nueh
2025-11-28 14:22:05 +03:00
parent 2a25be5aa4
commit 9fcfac87d4
9 changed files with 624 additions and 76 deletions

View 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)));
});
});
}