Files
eatvio_app/test/features/auth/models/credentials_model_test.dart
2025-11-28 14:22:05 +03:00

63 lines
1.7 KiB
Dart

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