forked from eatvio/eatvio_app
Merge remote-tracking branch 'upstream/main' into issue-975
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import 'package:eatvio_app/features/chat/models/order_id_to_conversation_model.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import '../../../fixtures/fixture_reader.dart';
|
||||
|
||||
void main() {
|
||||
group('OrderIdToConversationModel', () {
|
||||
test('fromJson создаёт модель из JSON фикстуры', () {
|
||||
final json = FixtureReader.readAsMap(
|
||||
'chat/payments/order_id_to_chat_uuid_response.json',
|
||||
);
|
||||
|
||||
final model = OrderIdToConversationModel.fromJson(json);
|
||||
|
||||
expect(model.chosenPlanId, 12);
|
||||
expect(
|
||||
model.conversationUuid,
|
||||
'fbd81429-8019-499a-80e8-e3933cc4d872',
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -1,25 +1,47 @@
|
||||
import 'package:eatvio_app/features/chat/models/payment_model.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import '../../../fixtures/fixture_reader.dart';
|
||||
|
||||
void main() {
|
||||
group('PaymentModel', () {
|
||||
test('создает PaymentModel с правильными значениями', () {
|
||||
final model = PaymentModel(
|
||||
paymentUrl: 'https://example.com/payment',
|
||||
);
|
||||
final model = PaymentModel(paymentUrl: 'https://example.com/payment');
|
||||
|
||||
expect(model.paymentUrl, 'https://example.com/payment');
|
||||
});
|
||||
|
||||
test('fromJson создает PaymentModel из JSON', () {
|
||||
final json = {
|
||||
'checkout_url': 'https://example.com/payment',
|
||||
};
|
||||
final json = {'checkout_url': 'https://example.com/payment'};
|
||||
|
||||
final model = PaymentModel.fromJson(json);
|
||||
|
||||
expect(model.paymentUrl, 'https://example.com/payment');
|
||||
});
|
||||
|
||||
test(
|
||||
'fromJson парсит ответ alfa-bank (checkout_url, order_id, payment_provider)',
|
||||
() {
|
||||
final json = FixtureReader.readAsMap(
|
||||
'chat/payments/payment_response_alfa_bank.json',
|
||||
);
|
||||
|
||||
final model = PaymentModel.fromJson(json);
|
||||
|
||||
expect(model.paymentUrl, 'https://qr.nspk.ru/ASDFASDFASDFASDF');
|
||||
expect(model.orderId, 'alfa_c29_k15138_t1712345678_r1234');
|
||||
expect(model.paymentProvider, 'alfa-bank');
|
||||
},
|
||||
);
|
||||
|
||||
test('fromJson парсит mock-ответ (checkout_url без order_id)', () {
|
||||
final json = FixtureReader.readAsMap('chat/payments/payment_response.json');
|
||||
|
||||
final model = PaymentModel.fromJson(json);
|
||||
|
||||
expect(model.paymentUrl, 'https://example.com/checkout/payment-123');
|
||||
expect(model.orderId, isNull);
|
||||
expect(model.paymentProvider, isNull);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user