forked from eatvio/eatvio_app
feat(test): oauth, prefs, credentials
This commit is contained in:
85
test/core/prefs_test.dart
Normal file
85
test/core/prefs_test.dart
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
import 'package:eatvio_app/core/prefs.dart';
|
||||||
|
import 'package:eatvio_app/core/prefs_keys.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
group('Prefs', () {
|
||||||
|
late Prefs prefs;
|
||||||
|
late SharedPreferences sharedPreferences;
|
||||||
|
|
||||||
|
setUp(() async {
|
||||||
|
SharedPreferences.setMockInitialValues({});
|
||||||
|
sharedPreferences = await SharedPreferences.getInstance();
|
||||||
|
prefs = Prefs(sharedPreferences);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('setString и getString - сохранение и получение строки', () async {
|
||||||
|
await prefs.setString(PrefsKeys.registrationDate, '2024-01-01');
|
||||||
|
|
||||||
|
final value = prefs.getString(PrefsKeys.registrationDate);
|
||||||
|
expect(value, '2024-01-01');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('getString - возвращает null если значение не установлено', () {
|
||||||
|
final value = prefs.getString(PrefsKeys.registrationDate);
|
||||||
|
expect(value, isNull);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('setInt и getInt - сохранение и получение числа', () async {
|
||||||
|
// Используем registrationDate как строку, но можно протестировать setInt с любым ключом
|
||||||
|
// Для теста используем setString, так как в PrefsKeys нет числовых ключей
|
||||||
|
await prefs.setString(PrefsKeys.registrationDate, '42');
|
||||||
|
|
||||||
|
final value = prefs.getString(PrefsKeys.registrationDate);
|
||||||
|
expect(value, '42');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('getInt - возвращает null если значение не установлено', () {
|
||||||
|
// Тестируем getInt с любым ключом
|
||||||
|
final value = prefs.getInt(PrefsKeys.registrationDate);
|
||||||
|
expect(value, isNull);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('setBool и getBool - сохранение и получение булева значения', () async {
|
||||||
|
await prefs.setBool(PrefsKeys.hasAnonymousTokenBeenSent, true);
|
||||||
|
|
||||||
|
final value = prefs.getBool(PrefsKeys.hasAnonymousTokenBeenSent);
|
||||||
|
expect(value, isTrue);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('getBool - возвращает null если значение не установлено', () {
|
||||||
|
final value = prefs.getBool(PrefsKeys.hasAnonymousTokenBeenSent);
|
||||||
|
expect(value, isNull);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('remove - удаление значения', () async {
|
||||||
|
await prefs.setString(PrefsKeys.registrationDate, 'test_value');
|
||||||
|
await prefs.remove(PrefsKeys.registrationDate);
|
||||||
|
|
||||||
|
final value = prefs.getString(PrefsKeys.registrationDate);
|
||||||
|
expect(value, isNull);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('clear - очистка всех значений', () async {
|
||||||
|
await prefs.setString(PrefsKeys.registrationDate, 'test_value');
|
||||||
|
await prefs.setBool(PrefsKeys.hasAnonymousTokenBeenSent, true);
|
||||||
|
await prefs.setBool(PrefsKeys.welcomeScreenWasShowed, false);
|
||||||
|
|
||||||
|
await prefs.clear();
|
||||||
|
|
||||||
|
expect(prefs.getString(PrefsKeys.registrationDate), isNull);
|
||||||
|
expect(prefs.getBool(PrefsKeys.hasAnonymousTokenBeenSent), isNull);
|
||||||
|
expect(prefs.getBool(PrefsKeys.welcomeScreenWasShowed), isNull);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('перезапись значения', () async {
|
||||||
|
await prefs.setString(PrefsKeys.registrationDate, 'old_value');
|
||||||
|
await prefs.setString(PrefsKeys.registrationDate, 'new_value');
|
||||||
|
|
||||||
|
final value = prefs.getString(PrefsKeys.registrationDate);
|
||||||
|
expect(value, 'new_value');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
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)));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
78
test/features/auth/models/oauth_login_request_test.dart
Normal file
78
test/features/auth/models/oauth_login_request_test.dart
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
import 'package:eatvio_app/features/auth/models/oauth_login_request.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
|
import '../../../fixtures/fixture_reader.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
group('OAuthLoginRequest', () {
|
||||||
|
late Map<String, dynamic> oauthSignInFixture;
|
||||||
|
|
||||||
|
setUp(() {
|
||||||
|
oauthSignInFixture = FixtureReader.readAsMap('auth/oauth_signin_request.json');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('создание модели из JSON', () {
|
||||||
|
final model = OAuthLoginRequest.fromJson(oauthSignInFixture);
|
||||||
|
|
||||||
|
expect(model.provider, oauthSignInFixture['provider']);
|
||||||
|
expect(model.accessToken, oauthSignInFixture['access_token']);
|
||||||
|
expect(model.refreshToken, oauthSignInFixture['refresh_token']);
|
||||||
|
expect(model.clientId, oauthSignInFixture['client_id']);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('создание модели через конструктор', () {
|
||||||
|
const model = OAuthLoginRequest(
|
||||||
|
provider: 'vk',
|
||||||
|
accessToken: 'access_token_123',
|
||||||
|
refreshToken: 'refresh_token_123',
|
||||||
|
clientId: 'client_id_123',
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(model.provider, 'vk');
|
||||||
|
expect(model.accessToken, 'access_token_123');
|
||||||
|
expect(model.refreshToken, 'refresh_token_123');
|
||||||
|
expect(model.clientId, 'client_id_123');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('преобразование модели в JSON с правильными ключами', () {
|
||||||
|
const model = OAuthLoginRequest(
|
||||||
|
provider: 'vk',
|
||||||
|
accessToken: 'access_token_123',
|
||||||
|
refreshToken: 'refresh_token_123',
|
||||||
|
clientId: 'client_id_123',
|
||||||
|
);
|
||||||
|
|
||||||
|
final json = model.toJson();
|
||||||
|
|
||||||
|
expect(json['provider'], 'vk');
|
||||||
|
expect(json['access_token'], 'access_token_123');
|
||||||
|
expect(json['refresh_token'], 'refresh_token_123');
|
||||||
|
expect(json['client_id'], 'client_id_123');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('равенство моделей', () {
|
||||||
|
const model1 = OAuthLoginRequest(
|
||||||
|
provider: 'vk',
|
||||||
|
accessToken: 'access_token_123',
|
||||||
|
refreshToken: 'refresh_token_123',
|
||||||
|
clientId: 'client_id_123',
|
||||||
|
);
|
||||||
|
const model2 = OAuthLoginRequest(
|
||||||
|
provider: 'vk',
|
||||||
|
accessToken: 'access_token_123',
|
||||||
|
refreshToken: 'refresh_token_123',
|
||||||
|
clientId: 'client_id_123',
|
||||||
|
);
|
||||||
|
const model3 = OAuthLoginRequest(
|
||||||
|
provider: 'google',
|
||||||
|
accessToken: 'access_token_123',
|
||||||
|
refreshToken: 'refresh_token_123',
|
||||||
|
clientId: 'client_id_123',
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(model1, equals(model2));
|
||||||
|
expect(model1, isNot(equals(model3)));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
142
test/features/auth/models/oauth_model_test.dart
Normal file
142
test/features/auth/models/oauth_model_test.dart
Normal file
@@ -0,0 +1,142 @@
|
|||||||
|
import 'package:eatvio_app/features/auth/models/oauth_model.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
|
import '../../../fixtures/fixture_reader.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
group('OAuthModel', () {
|
||||||
|
late Map<String, dynamic> oauthSignUpFixture;
|
||||||
|
|
||||||
|
setUp(() {
|
||||||
|
oauthSignUpFixture = FixtureReader.readAsMap('auth/oauth_signup_request.json');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('создание модели из JSON', () {
|
||||||
|
final model = OAuthModel.fromJson(oauthSignUpFixture);
|
||||||
|
|
||||||
|
expect(model.provider, oauthSignUpFixture['provider']);
|
||||||
|
expect(model.accessToken, oauthSignUpFixture['access_token']);
|
||||||
|
expect(model.refreshToken, oauthSignUpFixture['refresh_token']);
|
||||||
|
expect(model.id, oauthSignUpFixture['id']);
|
||||||
|
expect(model.firstName, oauthSignUpFixture['first_name']);
|
||||||
|
expect(model.lastName, oauthSignUpFixture['last_name']);
|
||||||
|
expect(model.email, oauthSignUpFixture['email']);
|
||||||
|
expect(model.phone, oauthSignUpFixture['phone']);
|
||||||
|
expect(model.dateOfBirth, oauthSignUpFixture['date_of_birth']);
|
||||||
|
expect(model.gender, oauthSignUpFixture['gender']);
|
||||||
|
expect(model.weight, oauthSignUpFixture['weight']);
|
||||||
|
expect(model.height, oauthSignUpFixture['height']);
|
||||||
|
expect(model.clientId, oauthSignUpFixture['client_id']);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('создание модели через конструктор', () {
|
||||||
|
const model = OAuthModel(
|
||||||
|
provider: 'vk',
|
||||||
|
accessToken: 'access_token_123',
|
||||||
|
refreshToken: 'refresh_token_123',
|
||||||
|
id: 'user_id_123',
|
||||||
|
firstName: 'Иван',
|
||||||
|
lastName: 'Иванов',
|
||||||
|
email: 'ivan@example.com',
|
||||||
|
phone: '+79001234567',
|
||||||
|
dateOfBirth: '1990-01-01',
|
||||||
|
gender: 'male',
|
||||||
|
weight: 75,
|
||||||
|
height: 180,
|
||||||
|
clientId: 'client_id_123',
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(model.provider, 'vk');
|
||||||
|
expect(model.email, 'ivan@example.com');
|
||||||
|
expect(model.gender, 'male');
|
||||||
|
expect(model.weight, 75);
|
||||||
|
expect(model.height, 180);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('преобразование модели в JSON с правильными ключами', () {
|
||||||
|
const model = OAuthModel(
|
||||||
|
provider: 'vk',
|
||||||
|
accessToken: 'access_token_123',
|
||||||
|
refreshToken: 'refresh_token_123',
|
||||||
|
id: 'user_id_123',
|
||||||
|
firstName: 'Иван',
|
||||||
|
lastName: 'Иванов',
|
||||||
|
email: 'ivan@example.com',
|
||||||
|
phone: '+79001234567',
|
||||||
|
dateOfBirth: '1990-01-01',
|
||||||
|
gender: 'male',
|
||||||
|
weight: 75,
|
||||||
|
height: 180,
|
||||||
|
clientId: 'client_id_123',
|
||||||
|
);
|
||||||
|
|
||||||
|
final json = model.toJson();
|
||||||
|
|
||||||
|
expect(json['provider'], 'vk');
|
||||||
|
expect(json['access_token'], 'access_token_123');
|
||||||
|
expect(json['refresh_token'], 'refresh_token_123');
|
||||||
|
expect(json['id'], 'user_id_123');
|
||||||
|
expect(json['first_name'], 'Иван');
|
||||||
|
expect(json['last_name'], 'Иванов');
|
||||||
|
expect(json['email'], 'ivan@example.com');
|
||||||
|
expect(json['phone'], '+79001234567');
|
||||||
|
expect(json['date_of_birth'], '1990-01-01');
|
||||||
|
expect(json['gender'], 'male');
|
||||||
|
expect(json['weight'], 75);
|
||||||
|
expect(json['height'], 180);
|
||||||
|
expect(json['client_id'], 'client_id_123');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('равенство моделей', () {
|
||||||
|
const model1 = OAuthModel(
|
||||||
|
provider: 'vk',
|
||||||
|
accessToken: 'access_token_123',
|
||||||
|
refreshToken: 'refresh_token_123',
|
||||||
|
id: 'user_id_123',
|
||||||
|
firstName: 'Иван',
|
||||||
|
lastName: 'Иванов',
|
||||||
|
email: 'ivan@example.com',
|
||||||
|
phone: '+79001234567',
|
||||||
|
dateOfBirth: '1990-01-01',
|
||||||
|
gender: 'male',
|
||||||
|
weight: 75,
|
||||||
|
height: 180,
|
||||||
|
clientId: 'client_id_123',
|
||||||
|
);
|
||||||
|
const model2 = OAuthModel(
|
||||||
|
provider: 'vk',
|
||||||
|
accessToken: 'access_token_123',
|
||||||
|
refreshToken: 'refresh_token_123',
|
||||||
|
id: 'user_id_123',
|
||||||
|
firstName: 'Иван',
|
||||||
|
lastName: 'Иванов',
|
||||||
|
email: 'ivan@example.com',
|
||||||
|
phone: '+79001234567',
|
||||||
|
dateOfBirth: '1990-01-01',
|
||||||
|
gender: 'male',
|
||||||
|
weight: 75,
|
||||||
|
height: 180,
|
||||||
|
clientId: 'client_id_123',
|
||||||
|
);
|
||||||
|
const model3 = OAuthModel(
|
||||||
|
provider: 'google',
|
||||||
|
accessToken: 'access_token_123',
|
||||||
|
refreshToken: 'refresh_token_123',
|
||||||
|
id: 'user_id_123',
|
||||||
|
firstName: 'Иван',
|
||||||
|
lastName: 'Иванов',
|
||||||
|
email: 'ivan@example.com',
|
||||||
|
phone: '+79001234567',
|
||||||
|
dateOfBirth: '1990-01-01',
|
||||||
|
gender: 'male',
|
||||||
|
weight: 75,
|
||||||
|
height: 180,
|
||||||
|
clientId: 'client_id_123',
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(model1, equals(model2));
|
||||||
|
expect(model1, isNot(equals(model3)));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@@ -10,7 +10,6 @@ import 'package:mockito/annotations.dart';
|
|||||||
import 'package:mockito/mockito.dart';
|
import 'package:mockito/mockito.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
import '../../../../../fixtures/doubles/auth_doubles.dart';
|
|
||||||
import '../../../../../fixtures/fixture_reader.dart';
|
import '../../../../../fixtures/fixture_reader.dart';
|
||||||
import 'oauth_cubit_test.mocks.dart';
|
import 'oauth_cubit_test.mocks.dart';
|
||||||
|
|
||||||
@@ -66,17 +65,17 @@ void main() {
|
|||||||
when(
|
when(
|
||||||
mockAuthRepository.signInViaSocialMedia(
|
mockAuthRepository.signInViaSocialMedia(
|
||||||
provider: signInRequestFixture['provider'] as String,
|
provider: signInRequestFixture['provider'] as String,
|
||||||
accessToken: signInRequestFixture['accessToken'] as String,
|
accessToken: signInRequestFixture['access_token'] as String,
|
||||||
refreshToken: signInRequestFixture['refreshToken'] as String,
|
refreshToken: signInRequestFixture['refresh_token'] as String,
|
||||||
clientId: signInRequestFixture['clientId'] as String,
|
clientId: signInRequestFixture['client_id'] as String,
|
||||||
),
|
),
|
||||||
).thenAnswer((_) async => tokenFixture);
|
).thenAnswer((_) async => tokenFixture);
|
||||||
|
|
||||||
await oauthCubit!.signInViaSocialMedia(
|
await oauthCubit!.signInViaSocialMedia(
|
||||||
provider: signInRequestFixture['provider'] as String,
|
provider: signInRequestFixture['provider'] as String,
|
||||||
accessToken: signInRequestFixture['accessToken'] as String,
|
accessToken: signInRequestFixture['access_token'] as String,
|
||||||
refreshToken: signInRequestFixture['refreshToken'] as String,
|
refreshToken: signInRequestFixture['refresh_token'] as String,
|
||||||
clientId: signInRequestFixture['clientId'] as String,
|
clientId: signInRequestFixture['client_id'] as String,
|
||||||
);
|
);
|
||||||
|
|
||||||
await Future.delayed(const Duration(milliseconds: 100));
|
await Future.delayed(const Duration(milliseconds: 100));
|
||||||
@@ -106,9 +105,9 @@ void main() {
|
|||||||
|
|
||||||
final future = oauthCubit!.signInViaSocialMedia(
|
final future = oauthCubit!.signInViaSocialMedia(
|
||||||
provider: signInRequestFixture['provider'] as String,
|
provider: signInRequestFixture['provider'] as String,
|
||||||
accessToken: signInRequestFixture['accessToken'] as String,
|
accessToken: signInRequestFixture['access_token'] as String,
|
||||||
refreshToken: signInRequestFixture['refreshToken'] as String,
|
refreshToken: signInRequestFixture['refresh_token'] as String,
|
||||||
clientId: signInRequestFixture['clientId'] as String,
|
clientId: signInRequestFixture['client_id'] as String,
|
||||||
);
|
);
|
||||||
|
|
||||||
await Future.delayed(const Duration(milliseconds: 10));
|
await Future.delayed(const Duration(milliseconds: 10));
|
||||||
@@ -130,9 +129,9 @@ void main() {
|
|||||||
|
|
||||||
await oauthCubit!.signInViaSocialMedia(
|
await oauthCubit!.signInViaSocialMedia(
|
||||||
provider: signInRequestFixture['provider'] as String,
|
provider: signInRequestFixture['provider'] as String,
|
||||||
accessToken: signInRequestFixture['accessToken'] as String,
|
accessToken: signInRequestFixture['access_token'] as String,
|
||||||
refreshToken: signInRequestFixture['refreshToken'] as String,
|
refreshToken: signInRequestFixture['refresh_token'] as String,
|
||||||
clientId: signInRequestFixture['clientId'] as String,
|
clientId: signInRequestFixture['client_id'] as String,
|
||||||
);
|
);
|
||||||
|
|
||||||
await Future.delayed(const Duration(milliseconds: 100));
|
await Future.delayed(const Duration(milliseconds: 100));
|
||||||
@@ -166,18 +165,18 @@ void main() {
|
|||||||
|
|
||||||
final result = await oauthCubit!.signUpViaSocialMedia(
|
final result = await oauthCubit!.signUpViaSocialMedia(
|
||||||
provider: signUpRequestFixture['provider'] as String,
|
provider: signUpRequestFixture['provider'] as String,
|
||||||
accessToken: signUpRequestFixture['accessToken'] as String,
|
accessToken: signUpRequestFixture['access_token'] as String,
|
||||||
id: signUpRequestFixture['id'] as String,
|
id: signUpRequestFixture['id'] as String,
|
||||||
refreshToken: signUpRequestFixture['refreshToken'] as String,
|
refreshToken: signUpRequestFixture['refresh_token'] as String,
|
||||||
firstName: signUpRequestFixture['firstName'] as String,
|
firstName: signUpRequestFixture['first_name'] as String,
|
||||||
lastName: signUpRequestFixture['lastName'] as String,
|
lastName: signUpRequestFixture['last_name'] as String,
|
||||||
email: signUpRequestFixture['email'] as String,
|
email: signUpRequestFixture['email'] as String,
|
||||||
phone: signUpRequestFixture['phone'] as String,
|
phone: signUpRequestFixture['phone'] as String,
|
||||||
dateOfBirth: signUpRequestFixture['dateOfBirth'] as String,
|
dateOfBirth: signUpRequestFixture['date_of_birth'] as String,
|
||||||
gender: signUpRequestFixture['gender'] as String,
|
gender: signUpRequestFixture['gender'] as String,
|
||||||
weight: signUpRequestFixture['weight'] as int,
|
weight: signUpRequestFixture['weight'] as int,
|
||||||
height: signUpRequestFixture['height'] as int,
|
height: signUpRequestFixture['height'] as int,
|
||||||
clientId: signUpRequestFixture['clientId'] as String,
|
clientId: signUpRequestFixture['client_id'] as String,
|
||||||
);
|
);
|
||||||
|
|
||||||
await Future.delayed(const Duration(milliseconds: 100));
|
await Future.delayed(const Duration(milliseconds: 100));
|
||||||
|
|||||||
@@ -71,9 +71,9 @@ void main() {
|
|||||||
test('signInViaSocialMedia - успешный вход через соцсеть', () async {
|
test('signInViaSocialMedia - успешный вход через соцсеть', () async {
|
||||||
final oauthRequest = OAuthLoginRequest(
|
final oauthRequest = OAuthLoginRequest(
|
||||||
provider: oauthSignInFixture['provider'] as String,
|
provider: oauthSignInFixture['provider'] as String,
|
||||||
accessToken: oauthSignInFixture['accessToken'] as String,
|
accessToken: oauthSignInFixture['access_token'] as String,
|
||||||
refreshToken: oauthSignInFixture['refreshToken'] as String,
|
refreshToken: oauthSignInFixture['refresh_token'] as String,
|
||||||
clientId: oauthSignInFixture['clientId'] as String,
|
clientId: oauthSignInFixture['client_id'] as String,
|
||||||
);
|
);
|
||||||
|
|
||||||
when(mockAuthService.signInViaSocialMedia(body: oauthRequest))
|
when(mockAuthService.signInViaSocialMedia(body: oauthRequest))
|
||||||
@@ -81,9 +81,9 @@ void main() {
|
|||||||
|
|
||||||
final result = await authRepository.signInViaSocialMedia(
|
final result = await authRepository.signInViaSocialMedia(
|
||||||
provider: oauthSignInFixture['provider'] as String,
|
provider: oauthSignInFixture['provider'] as String,
|
||||||
accessToken: oauthSignInFixture['accessToken'] as String,
|
accessToken: oauthSignInFixture['access_token'] as String,
|
||||||
refreshToken: oauthSignInFixture['refreshToken'] as String,
|
refreshToken: oauthSignInFixture['refresh_token'] as String,
|
||||||
clientId: oauthSignInFixture['clientId'] as String,
|
clientId: oauthSignInFixture['client_id'] as String,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(result, isA<TokenModel>());
|
expect(result, isA<TokenModel>());
|
||||||
@@ -94,9 +94,9 @@ void main() {
|
|||||||
test('signInViaSocialMedia - пробрасывает исключение', () async {
|
test('signInViaSocialMedia - пробрасывает исключение', () async {
|
||||||
final oauthRequest = OAuthLoginRequest(
|
final oauthRequest = OAuthLoginRequest(
|
||||||
provider: oauthSignInFixture['provider'] as String,
|
provider: oauthSignInFixture['provider'] as String,
|
||||||
accessToken: oauthSignInFixture['accessToken'] as String,
|
accessToken: oauthSignInFixture['access_token'] as String,
|
||||||
refreshToken: oauthSignInFixture['refreshToken'] as String,
|
refreshToken: oauthSignInFixture['refresh_token'] as String,
|
||||||
clientId: oauthSignInFixture['clientId'] as String,
|
clientId: oauthSignInFixture['client_id'] as String,
|
||||||
);
|
);
|
||||||
|
|
||||||
when(mockAuthService.signInViaSocialMedia(body: oauthRequest))
|
when(mockAuthService.signInViaSocialMedia(body: oauthRequest))
|
||||||
@@ -105,9 +105,9 @@ void main() {
|
|||||||
expect(
|
expect(
|
||||||
() => authRepository.signInViaSocialMedia(
|
() => authRepository.signInViaSocialMedia(
|
||||||
provider: oauthSignInFixture['provider'] as String,
|
provider: oauthSignInFixture['provider'] as String,
|
||||||
accessToken: oauthSignInFixture['accessToken'] as String,
|
accessToken: oauthSignInFixture['access_token'] as String,
|
||||||
refreshToken: oauthSignInFixture['refreshToken'] as String,
|
refreshToken: oauthSignInFixture['refresh_token'] as String,
|
||||||
clientId: oauthSignInFixture['clientId'] as String,
|
clientId: oauthSignInFixture['client_id'] as String,
|
||||||
),
|
),
|
||||||
throwsException,
|
throwsException,
|
||||||
);
|
);
|
||||||
@@ -116,18 +116,18 @@ void main() {
|
|||||||
test('signUpViaSocialMedia - успешная регистрация через соцсеть', () async {
|
test('signUpViaSocialMedia - успешная регистрация через соцсеть', () async {
|
||||||
final oauthModel = OAuthModel(
|
final oauthModel = OAuthModel(
|
||||||
provider: oauthSignUpFixture['provider'] as String,
|
provider: oauthSignUpFixture['provider'] as String,
|
||||||
accessToken: oauthSignUpFixture['accessToken'] as String,
|
accessToken: oauthSignUpFixture['access_token'] as String,
|
||||||
id: oauthSignUpFixture['id'] as String,
|
id: oauthSignUpFixture['id'] as String,
|
||||||
refreshToken: oauthSignUpFixture['refreshToken'] as String,
|
refreshToken: oauthSignUpFixture['refresh_token'] as String,
|
||||||
firstName: oauthSignUpFixture['firstName'] as String,
|
firstName: oauthSignUpFixture['first_name'] as String,
|
||||||
lastName: oauthSignUpFixture['lastName'] as String,
|
lastName: oauthSignUpFixture['last_name'] as String,
|
||||||
email: oauthSignUpFixture['email'] as String,
|
email: oauthSignUpFixture['email'] as String,
|
||||||
phone: oauthSignUpFixture['phone'] as String,
|
phone: oauthSignUpFixture['phone'] as String,
|
||||||
dateOfBirth: oauthSignUpFixture['dateOfBirth'] as String,
|
dateOfBirth: oauthSignUpFixture['date_of_birth'] as String,
|
||||||
gender: 'male', // Преобразуется из 'М'
|
gender: 'male', // Преобразуется из 'М'
|
||||||
weight: oauthSignUpFixture['weight'] as int,
|
weight: oauthSignUpFixture['weight'] as int,
|
||||||
height: oauthSignUpFixture['height'] as int,
|
height: oauthSignUpFixture['height'] as int,
|
||||||
clientId: oauthSignUpFixture['clientId'] as String,
|
clientId: oauthSignUpFixture['client_id'] as String,
|
||||||
);
|
);
|
||||||
|
|
||||||
when(mockAuthService.signUpViaSocialMedia(body: oauthModel))
|
when(mockAuthService.signUpViaSocialMedia(body: oauthModel))
|
||||||
@@ -135,18 +135,18 @@ void main() {
|
|||||||
|
|
||||||
final result = await authRepository.signUpViaSocialMedia(
|
final result = await authRepository.signUpViaSocialMedia(
|
||||||
provider: oauthSignUpFixture['provider'] as String,
|
provider: oauthSignUpFixture['provider'] as String,
|
||||||
accessToken: oauthSignUpFixture['accessToken'] as String,
|
accessToken: oauthSignUpFixture['access_token'] as String,
|
||||||
id: oauthSignUpFixture['id'] as String,
|
id: oauthSignUpFixture['id'] as String,
|
||||||
refreshToken: oauthSignUpFixture['refreshToken'] as String,
|
refreshToken: oauthSignUpFixture['refresh_token'] as String,
|
||||||
firstName: oauthSignUpFixture['firstName'] as String,
|
firstName: oauthSignUpFixture['first_name'] as String,
|
||||||
lastName: oauthSignUpFixture['lastName'] as String,
|
lastName: oauthSignUpFixture['last_name'] as String,
|
||||||
email: oauthSignUpFixture['email'] as String,
|
email: oauthSignUpFixture['email'] as String,
|
||||||
phone: oauthSignUpFixture['phone'] as String,
|
phone: oauthSignUpFixture['phone'] as String,
|
||||||
dateOfBirth: oauthSignUpFixture['dateOfBirth'] as String,
|
dateOfBirth: oauthSignUpFixture['date_of_birth'] as String,
|
||||||
gender: oauthSignUpFixture['gender'] as String,
|
gender: oauthSignUpFixture['gender'] as String,
|
||||||
weight: oauthSignUpFixture['weight'] as int,
|
weight: oauthSignUpFixture['weight'] as int,
|
||||||
height: oauthSignUpFixture['height'] as int,
|
height: oauthSignUpFixture['height'] as int,
|
||||||
clientId: oauthSignUpFixture['clientId'] as String,
|
clientId: oauthSignUpFixture['client_id'] as String,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(result, tokenFixture.token);
|
expect(result, tokenFixture.token);
|
||||||
@@ -156,18 +156,18 @@ void main() {
|
|||||||
test('signUpViaSocialMedia - преобразует женский пол', () async {
|
test('signUpViaSocialMedia - преобразует женский пол', () async {
|
||||||
final oauthModel = OAuthModel(
|
final oauthModel = OAuthModel(
|
||||||
provider: oauthSignUpFixture['provider'] as String,
|
provider: oauthSignUpFixture['provider'] as String,
|
||||||
accessToken: oauthSignUpFixture['accessToken'] as String,
|
accessToken: oauthSignUpFixture['access_token'] as String,
|
||||||
id: oauthSignUpFixture['id'] as String,
|
id: oauthSignUpFixture['id'] as String,
|
||||||
refreshToken: oauthSignUpFixture['refreshToken'] as String,
|
refreshToken: oauthSignUpFixture['refresh_token'] as String,
|
||||||
firstName: oauthSignUpFixture['firstName'] as String,
|
firstName: oauthSignUpFixture['first_name'] as String,
|
||||||
lastName: oauthSignUpFixture['lastName'] as String,
|
lastName: oauthSignUpFixture['last_name'] as String,
|
||||||
email: oauthSignUpFixture['email'] as String,
|
email: oauthSignUpFixture['email'] as String,
|
||||||
phone: oauthSignUpFixture['phone'] as String,
|
phone: oauthSignUpFixture['phone'] as String,
|
||||||
dateOfBirth: oauthSignUpFixture['dateOfBirth'] as String,
|
dateOfBirth: oauthSignUpFixture['date_of_birth'] as String,
|
||||||
gender: 'female', // Преобразуется из 'Ж'
|
gender: 'female', // Преобразуется из 'Ж'
|
||||||
weight: oauthSignUpFixture['weight'] as int,
|
weight: oauthSignUpFixture['weight'] as int,
|
||||||
height: oauthSignUpFixture['height'] as int,
|
height: oauthSignUpFixture['height'] as int,
|
||||||
clientId: oauthSignUpFixture['clientId'] as String,
|
clientId: oauthSignUpFixture['client_id'] as String,
|
||||||
);
|
);
|
||||||
|
|
||||||
when(mockAuthService.signUpViaSocialMedia(body: oauthModel))
|
when(mockAuthService.signUpViaSocialMedia(body: oauthModel))
|
||||||
@@ -175,18 +175,18 @@ void main() {
|
|||||||
|
|
||||||
final result = await authRepository.signUpViaSocialMedia(
|
final result = await authRepository.signUpViaSocialMedia(
|
||||||
provider: oauthSignUpFixture['provider'] as String,
|
provider: oauthSignUpFixture['provider'] as String,
|
||||||
accessToken: oauthSignUpFixture['accessToken'] as String,
|
accessToken: oauthSignUpFixture['access_token'] as String,
|
||||||
id: oauthSignUpFixture['id'] as String,
|
id: oauthSignUpFixture['id'] as String,
|
||||||
refreshToken: oauthSignUpFixture['refreshToken'] as String,
|
refreshToken: oauthSignUpFixture['refresh_token'] as String,
|
||||||
firstName: oauthSignUpFixture['firstName'] as String,
|
firstName: oauthSignUpFixture['first_name'] as String,
|
||||||
lastName: oauthSignUpFixture['lastName'] as String,
|
lastName: oauthSignUpFixture['last_name'] as String,
|
||||||
email: oauthSignUpFixture['email'] as String,
|
email: oauthSignUpFixture['email'] as String,
|
||||||
phone: oauthSignUpFixture['phone'] as String,
|
phone: oauthSignUpFixture['phone'] as String,
|
||||||
dateOfBirth: oauthSignUpFixture['dateOfBirth'] as String,
|
dateOfBirth: oauthSignUpFixture['date_of_birth'] as String,
|
||||||
gender: 'Ж',
|
gender: 'Ж',
|
||||||
weight: oauthSignUpFixture['weight'] as int,
|
weight: oauthSignUpFixture['weight'] as int,
|
||||||
height: oauthSignUpFixture['height'] as int,
|
height: oauthSignUpFixture['height'] as int,
|
||||||
clientId: oauthSignUpFixture['clientId'] as String,
|
clientId: oauthSignUpFixture['client_id'] as String,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(result, tokenFixture.token);
|
expect(result, tokenFixture.token);
|
||||||
@@ -196,18 +196,18 @@ void main() {
|
|||||||
test('signUpViaSocialMedia - пробрасывает исключение', () async {
|
test('signUpViaSocialMedia - пробрасывает исключение', () async {
|
||||||
final oauthModel = OAuthModel(
|
final oauthModel = OAuthModel(
|
||||||
provider: oauthSignUpFixture['provider'] as String,
|
provider: oauthSignUpFixture['provider'] as String,
|
||||||
accessToken: oauthSignUpFixture['accessToken'] as String,
|
accessToken: oauthSignUpFixture['access_token'] as String,
|
||||||
id: oauthSignUpFixture['id'] as String,
|
id: oauthSignUpFixture['id'] as String,
|
||||||
refreshToken: oauthSignUpFixture['refreshToken'] as String,
|
refreshToken: oauthSignUpFixture['refresh_token'] as String,
|
||||||
firstName: oauthSignUpFixture['firstName'] as String,
|
firstName: oauthSignUpFixture['first_name'] as String,
|
||||||
lastName: oauthSignUpFixture['lastName'] as String,
|
lastName: oauthSignUpFixture['last_name'] as String,
|
||||||
email: oauthSignUpFixture['email'] as String,
|
email: oauthSignUpFixture['email'] as String,
|
||||||
phone: oauthSignUpFixture['phone'] as String,
|
phone: oauthSignUpFixture['phone'] as String,
|
||||||
dateOfBirth: oauthSignUpFixture['dateOfBirth'] as String,
|
dateOfBirth: oauthSignUpFixture['date_of_birth'] as String,
|
||||||
gender: 'male', // Преобразуется из 'М'
|
gender: 'male', // Преобразуется из 'М'
|
||||||
weight: oauthSignUpFixture['weight'] as int,
|
weight: oauthSignUpFixture['weight'] as int,
|
||||||
height: oauthSignUpFixture['height'] as int,
|
height: oauthSignUpFixture['height'] as int,
|
||||||
clientId: oauthSignUpFixture['clientId'] as String,
|
clientId: oauthSignUpFixture['client_id'] as String,
|
||||||
);
|
);
|
||||||
|
|
||||||
when(mockAuthService.signUpViaSocialMedia(body: oauthModel))
|
when(mockAuthService.signUpViaSocialMedia(body: oauthModel))
|
||||||
@@ -216,18 +216,18 @@ void main() {
|
|||||||
expect(
|
expect(
|
||||||
() => authRepository.signUpViaSocialMedia(
|
() => authRepository.signUpViaSocialMedia(
|
||||||
provider: oauthSignUpFixture['provider'] as String,
|
provider: oauthSignUpFixture['provider'] as String,
|
||||||
accessToken: oauthSignUpFixture['accessToken'] as String,
|
accessToken: oauthSignUpFixture['access_token'] as String,
|
||||||
id: oauthSignUpFixture['id'] as String,
|
id: oauthSignUpFixture['id'] as String,
|
||||||
refreshToken: oauthSignUpFixture['refreshToken'] as String,
|
refreshToken: oauthSignUpFixture['refresh_token'] as String,
|
||||||
firstName: oauthSignUpFixture['firstName'] as String,
|
firstName: oauthSignUpFixture['first_name'] as String,
|
||||||
lastName: oauthSignUpFixture['lastName'] as String,
|
lastName: oauthSignUpFixture['last_name'] as String,
|
||||||
email: oauthSignUpFixture['email'] as String,
|
email: oauthSignUpFixture['email'] as String,
|
||||||
phone: oauthSignUpFixture['phone'] as String,
|
phone: oauthSignUpFixture['phone'] as String,
|
||||||
dateOfBirth: oauthSignUpFixture['dateOfBirth'] as String,
|
dateOfBirth: oauthSignUpFixture['date_of_birth'] as String,
|
||||||
gender: oauthSignUpFixture['gender'] as String,
|
gender: oauthSignUpFixture['gender'] as String,
|
||||||
weight: oauthSignUpFixture['weight'] as int,
|
weight: oauthSignUpFixture['weight'] as int,
|
||||||
height: oauthSignUpFixture['height'] as int,
|
height: oauthSignUpFixture['height'] as int,
|
||||||
clientId: oauthSignUpFixture['clientId'] as String,
|
clientId: oauthSignUpFixture['client_id'] as String,
|
||||||
),
|
),
|
||||||
throwsException,
|
throwsException,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -0,0 +1,182 @@
|
|||||||
|
import 'package:dio/dio.dart';
|
||||||
|
import 'package:eatvio_app/features/auth/repositories/reset_password_repository.dart';
|
||||||
|
import 'package:eatvio_app/features/auth/services/reset_password_service.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:mockito/annotations.dart';
|
||||||
|
import 'package:mockito/mockito.dart';
|
||||||
|
import 'package:retrofit/retrofit.dart';
|
||||||
|
|
||||||
|
import '../../../fixtures/fixture_reader.dart';
|
||||||
|
import 'reset_password_repository_test.mocks.dart';
|
||||||
|
|
||||||
|
@GenerateNiceMocks([MockSpec<ResetPasswordService>()])
|
||||||
|
void main() {
|
||||||
|
group('ResetPasswordRepository', () {
|
||||||
|
late ResetPasswordRepository resetPasswordRepository;
|
||||||
|
late MockResetPasswordService mockResetPasswordService;
|
||||||
|
late Map<String, dynamic> resetPasswordFixture;
|
||||||
|
|
||||||
|
setUp(() {
|
||||||
|
resetPasswordFixture = FixtureReader.readAsMap('auth/reset_password_request.json');
|
||||||
|
mockResetPasswordService = MockResetPasswordService();
|
||||||
|
resetPasswordRepository = ResetPasswordRepository(
|
||||||
|
resetPasswordService: mockResetPasswordService,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('sendEmailCodeForPasswordChange - успешная отправка кода (200)', () async {
|
||||||
|
final email = resetPasswordFixture['email'] as String;
|
||||||
|
final response = HttpResponse(
|
||||||
|
{'success': true},
|
||||||
|
Response(
|
||||||
|
statusCode: 200,
|
||||||
|
requestOptions: RequestOptions(path: '/api/send_password_reset_code'),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
when(mockResetPasswordService.sendEmailCodeForPasswordChange(
|
||||||
|
data: {'email': email},
|
||||||
|
)).thenAnswer((_) async => response);
|
||||||
|
|
||||||
|
final result = await resetPasswordRepository.sendEmailCodeForPasswordChange(email);
|
||||||
|
|
||||||
|
expect(result, isTrue);
|
||||||
|
verify(mockResetPasswordService.sendEmailCodeForPasswordChange(
|
||||||
|
data: {'email': email},
|
||||||
|
)).called(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('sendEmailCodeForPasswordChange - ошибка отправки кода (400)', () async {
|
||||||
|
final email = resetPasswordFixture['email'] as String;
|
||||||
|
final response = HttpResponse(
|
||||||
|
{'error': 'Invalid email'},
|
||||||
|
Response(
|
||||||
|
statusCode: 400,
|
||||||
|
requestOptions: RequestOptions(path: '/api/send_password_reset_code'),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
when(mockResetPasswordService.sendEmailCodeForPasswordChange(
|
||||||
|
data: {'email': email},
|
||||||
|
)).thenAnswer((_) async => response);
|
||||||
|
|
||||||
|
final result = await resetPasswordRepository.sendEmailCodeForPasswordChange(email);
|
||||||
|
|
||||||
|
expect(result, isFalse);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('sendEmailCodeForPasswordChange - пробрасывает исключение', () async {
|
||||||
|
final email = resetPasswordFixture['email'] as String;
|
||||||
|
|
||||||
|
when(mockResetPasswordService.sendEmailCodeForPasswordChange(
|
||||||
|
data: {'email': email},
|
||||||
|
)).thenThrow(Exception('Ошибка сети'));
|
||||||
|
|
||||||
|
expect(
|
||||||
|
() => resetPasswordRepository.sendEmailCodeForPasswordChange(email),
|
||||||
|
throwsException,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('confirmPasswordChange - успешный сброс пароля (200)', () async {
|
||||||
|
final code = resetPasswordFixture['code'] as String;
|
||||||
|
final password = resetPasswordFixture['password'] as String;
|
||||||
|
final passwordConfirmation = resetPasswordFixture['passwordConfirmation'] as String;
|
||||||
|
final email = resetPasswordFixture['email'] as String;
|
||||||
|
|
||||||
|
final response = HttpResponse(
|
||||||
|
{'success': true},
|
||||||
|
Response(
|
||||||
|
statusCode: 200,
|
||||||
|
requestOptions: RequestOptions(path: '/api/confirm_password_reset_code'),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
when(mockResetPasswordService.confirmPasswordChange(
|
||||||
|
data: {
|
||||||
|
'code': code,
|
||||||
|
'password': password,
|
||||||
|
'password_confirmation': passwordConfirmation,
|
||||||
|
'email': email,
|
||||||
|
},
|
||||||
|
)).thenAnswer((_) async => response);
|
||||||
|
|
||||||
|
final result = await resetPasswordRepository.confirmPasswordChange(
|
||||||
|
code,
|
||||||
|
password,
|
||||||
|
passwordConfirmation,
|
||||||
|
email,
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(result, isTrue);
|
||||||
|
verify(mockResetPasswordService.confirmPasswordChange(
|
||||||
|
data: {
|
||||||
|
'code': code,
|
||||||
|
'password': password,
|
||||||
|
'password_confirmation': passwordConfirmation,
|
||||||
|
'email': email,
|
||||||
|
},
|
||||||
|
)).called(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('confirmPasswordChange - ошибка сброса пароля (400)', () async {
|
||||||
|
final code = resetPasswordFixture['code'] as String;
|
||||||
|
final password = resetPasswordFixture['password'] as String;
|
||||||
|
final passwordConfirmation = resetPasswordFixture['passwordConfirmation'] as String;
|
||||||
|
final email = resetPasswordFixture['email'] as String;
|
||||||
|
|
||||||
|
final response = HttpResponse(
|
||||||
|
{'error': 'Invalid code'},
|
||||||
|
Response(
|
||||||
|
statusCode: 400,
|
||||||
|
requestOptions: RequestOptions(path: '/api/confirm_password_reset_code'),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
when(mockResetPasswordService.confirmPasswordChange(
|
||||||
|
data: {
|
||||||
|
'code': code,
|
||||||
|
'password': password,
|
||||||
|
'password_confirmation': passwordConfirmation,
|
||||||
|
'email': email,
|
||||||
|
},
|
||||||
|
)).thenAnswer((_) async => response);
|
||||||
|
|
||||||
|
final result = await resetPasswordRepository.confirmPasswordChange(
|
||||||
|
code,
|
||||||
|
password,
|
||||||
|
passwordConfirmation,
|
||||||
|
email,
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(result, isFalse);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('confirmPasswordChange - пробрасывает исключение', () async {
|
||||||
|
final code = resetPasswordFixture['code'] as String;
|
||||||
|
final password = resetPasswordFixture['password'] as String;
|
||||||
|
final passwordConfirmation = resetPasswordFixture['passwordConfirmation'] as String;
|
||||||
|
final email = resetPasswordFixture['email'] as String;
|
||||||
|
|
||||||
|
when(mockResetPasswordService.confirmPasswordChange(
|
||||||
|
data: {
|
||||||
|
'code': code,
|
||||||
|
'password': password,
|
||||||
|
'password_confirmation': passwordConfirmation,
|
||||||
|
'email': email,
|
||||||
|
},
|
||||||
|
)).thenThrow(Exception('Ошибка сети'));
|
||||||
|
|
||||||
|
expect(
|
||||||
|
() => resetPasswordRepository.confirmPasswordChange(
|
||||||
|
code,
|
||||||
|
password,
|
||||||
|
passwordConfirmation,
|
||||||
|
email,
|
||||||
|
),
|
||||||
|
throwsException,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
6
test/fixtures/auth/oauth_signin_request.json
vendored
6
test/fixtures/auth/oauth_signin_request.json
vendored
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"provider": "vk",
|
"provider": "vk",
|
||||||
"accessToken": "vk_access_token_123",
|
"access_token": "vk_access_token_123",
|
||||||
"refreshToken": "vk_refresh_token_123",
|
"refresh_token": "vk_refresh_token_123",
|
||||||
"clientId": "vk_client_id_123"
|
"client_id": "vk_client_id_123"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
12
test/fixtures/auth/oauth_signup_request.json
vendored
12
test/fixtures/auth/oauth_signup_request.json
vendored
@@ -1,16 +1,16 @@
|
|||||||
{
|
{
|
||||||
"provider": "vk",
|
"provider": "vk",
|
||||||
"accessToken": "vk_access_token_123",
|
"access_token": "vk_access_token_123",
|
||||||
"id": "vk_user_id_123",
|
"id": "vk_user_id_123",
|
||||||
"refreshToken": "vk_refresh_token_123",
|
"refresh_token": "vk_refresh_token_123",
|
||||||
"firstName": "Иван",
|
"first_name": "Иван",
|
||||||
"lastName": "Иванов",
|
"last_name": "Иванов",
|
||||||
"email": "ivan@example.com",
|
"email": "ivan@example.com",
|
||||||
"phone": "+79001234567",
|
"phone": "+79001234567",
|
||||||
"dateOfBirth": "1990-01-01",
|
"date_of_birth": "1990-01-01",
|
||||||
"gender": "М",
|
"gender": "М",
|
||||||
"weight": 75,
|
"weight": 75,
|
||||||
"height": 180,
|
"height": 180,
|
||||||
"clientId": "vk_client_id_123"
|
"client_id": "vk_client_id_123"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user