feat(sbp_payments): added tests for new chosen_plan_state fixtures and new tests for chat repo and service

This commit is contained in:
misha
2026-07-08 15:07:36 +03:00
parent e10610d93c
commit 51397003b5
10 changed files with 171 additions and 27 deletions

View File

@@ -4,6 +4,8 @@ import 'package:eatvio_app/features/plans/enums/chosen_plan_state_enum.dart';
import 'package:eatvio_app/features/plans/models/chosen_plan_model.dart';
import 'package:flutter_test/flutter_test.dart';
import '../../../fixtures/fixture_reader.dart';
void main() {
group('ChosenPlanModel', () {
test('создает ChosenPlanModel с правильными значениями', () {
@@ -140,6 +142,60 @@ void main() {
expect(json['consultant_id'], 1);
expect(json.containsKey('plan'), isTrue);
});
group('fromJson payment polling statuses', () {
test('fromJson парсит pending_payment из фикстуры', () {
final json = FixtureReader.readAsMap(
'chat/chosen_plan/chosen_plan_pending_payment_response.json',
);
final model = ChosenPlanModel.fromJson(json);
expect(model.id, 1);
expect(model.optionType, '1');
expect(model.chosenPlanState, ChosenPlanStateEnum.statePendingPayment);
expect(model.chatId, 'chat-1');
});
test('fromJson парсит paid из фикстуры', () {
final json = FixtureReader.readAsMap(
'chat/chosen_plan/chosen_plan_paid_response.json',
);
final model = ChosenPlanModel.fromJson(json);
expect(model.id, 1);
expect(model.optionType, '1');
expect(model.chosenPlanState, ChosenPlanStateEnum.statePaid);
expect(model.chatId, 'chat-1');
});
test('fromJson парсит payment_failed из фикстуры', () {
final json = FixtureReader.readAsMap(
'chat/chosen_plan/chosen_plan_payment_failed_response.json',
);
final model = ChosenPlanModel.fromJson(json);
expect(model.id, 1);
expect(model.optionType, '1');
expect(model.chosenPlanState, ChosenPlanStateEnum.statePaymentFailed);
expect(model.chatId, 'chat-1');
});
test('fromJson парсит canceled_by_the_initiator из фикстуры', () {
final json = FixtureReader.readAsMap(
'chat/chosen_plan/chosen_plan_canceled_by_the_initiator_response.json',
);
final model = ChosenPlanModel.fromJson(json);
expect(model.id, 1);
expect(model.optionType, '1');
expect(model.chosenPlanState, ChosenPlanStateEnum.stateCanceledByTheInitiator);
expect(model.chatId, 'chat-1');
});
});
});
group('parseChosenPlan', () {