forked from eatvio/eatvio_app
feat(payments): phase #1 tests and part of implementation
This commit is contained in:
@@ -4,6 +4,7 @@ import 'package:eatvio_app/features/chat/models/chat_messages_model.dart';
|
||||
import 'package:eatvio_app/features/chat/models/chat_room_model.dart'
|
||||
as chat_room;
|
||||
import 'package:eatvio_app/features/chat/models/chat_room_pagination_model.dart';
|
||||
import 'package:eatvio_app/features/chat/models/order_id_to_conversation_model.dart';
|
||||
import 'package:eatvio_app/features/chat/models/payment_model.dart';
|
||||
import 'package:eatvio_app/features/chat/models/plan_complain_model.dart';
|
||||
import 'package:eatvio_app/features/chat/services/chat_service.dart';
|
||||
@@ -221,14 +222,17 @@ void main() {
|
||||
final expectedPayment = PaymentModel.fromJson(paymentFixture);
|
||||
|
||||
when(
|
||||
mockChatService.getPaymentLink(id: planId),
|
||||
mockChatService.getPaymentLink(id: planId, body: {'payment_provider': 'mock'}),
|
||||
).thenAnswer((_) async => expectedPayment);
|
||||
|
||||
final result = await mockChatService.getPaymentLink(id: planId);
|
||||
final result = await mockChatService.getPaymentLink(
|
||||
id: planId,
|
||||
body: {'payment_provider': 'mock'},
|
||||
);
|
||||
|
||||
expect(result, isA<PaymentModel>());
|
||||
expect(result.paymentUrl, 'https://example.com/checkout/payment-123');
|
||||
verify(mockChatService.getPaymentLink(id: planId)).called(1);
|
||||
verify(mockChatService.getPaymentLink(id: planId, body: {'payment_provider': 'mock'})).called(1);
|
||||
});
|
||||
|
||||
test('getChosenPlan - возвращает выбранный план', () async {
|
||||
@@ -291,6 +295,31 @@ void main() {
|
||||
},
|
||||
);
|
||||
|
||||
test(
|
||||
'resolveOrderIdToConversation - возвращает модель по orderId',
|
||||
() async {
|
||||
const orderId = 'alfa_c29_k15138_t1712345678_r1234';
|
||||
final fixture = FixtureReader.readAsMap(
|
||||
'chat/payments/order_id_to_chat_uuid_response.json',
|
||||
);
|
||||
final expected = OrderIdToConversationModel.fromJson(fixture);
|
||||
|
||||
when(
|
||||
mockChatService.resolveOrderIdToConversation(orderId: orderId),
|
||||
).thenAnswer((_) async => expected);
|
||||
|
||||
final result = await mockChatService.resolveOrderIdToConversation(
|
||||
orderId: orderId,
|
||||
);
|
||||
|
||||
expect(result, isA<OrderIdToConversationModel>());
|
||||
expect(result.chosenPlanId, 12);
|
||||
verify(
|
||||
mockChatService.resolveOrderIdToConversation(orderId: orderId),
|
||||
).called(1);
|
||||
},
|
||||
);
|
||||
|
||||
test('getChatByUserSlug - возвращает HttpResponse', () async {
|
||||
const slug = 'user-slug';
|
||||
const chatId = 'chat-id-123';
|
||||
|
||||
Reference in New Issue
Block a user