Skip to content

Commit

Permalink
Added unit test for the API trading_platform_password_reset.
Browse files Browse the repository at this point in the history
  • Loading branch information
aliakbar-deriv authored and abedelaziz-deriv committed Jan 5, 2024
1 parent e0fc9e6 commit 41892a3
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/services/connection/api_manager/mock_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'dart:async';
import 'dart:convert';

import 'package:flutter/material.dart';

import 'package:flutter_deriv_api/api/models/enums.dart';
import 'package:flutter_deriv_api/basic_api/generated/forget_all_receive.dart';
import 'package:flutter_deriv_api/basic_api/generated/forget_receive.dart';
Expand Down Expand Up @@ -104,6 +103,7 @@ import 'mock_data/p2p/p2p_order_confirm_response.dart';
import 'mock_data/p2p/p2p_order_create_response.dart';
import 'mock_data/p2p/p2p_order_info_response.dart';
import 'mock_data/p2p/p2p_order_list_response.dart';
import 'mock_data/trading_platform/trading_platform_password_reset_response.dart';
import 'mock_data/user/get_financial_assessment_response.dart';
import 'mock_data/user/set_financial_assessment_response.dart';
import 'mock_data/user/tnc_approval_response.dart';
Expand Down Expand Up @@ -361,6 +361,8 @@ class MockAPI extends BaseAPI {
return topUpVirtualResponse;
case 'trading_durations':
return tradingDurationsResponse;
case 'trading_platform_password_reset':
return tradingPlatformPasswordResetResponse;
case 'trading_times':
return tradingTimesResponse;
case 'transaction':
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/// Mock data for trading platform password reset response.
const String tradingPlatformPasswordResetResponse = '''
{
"echo_req": {
"new_password": "<not shown>",
"platform": "dxtrade",
"trading_platform_password_reset": 1,
"verification_code": "VYt3xeeu"
},
"msg_type": "trading_platform_password_reset",
"trading_platform_password_reset": 1
}
''';
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import 'package:deriv_dependency_injector/dependency_injector.dart';
import 'package:flutter_deriv_api/api/api_initializer.dart';
import 'package:flutter_deriv_api/api/response/trading_platform_password_reset_response_extended.dart';
import 'package:flutter_deriv_api/api/response/trading_platform_password_reset_response_result.dart';
import 'package:flutter_deriv_api/basic_api/generated/trading_platform_password_reset_send.dart';
import 'package:flutter_deriv_api/services/connection/api_manager/mock_api.dart';
import 'package:flutter_test/flutter_test.dart';

void main() {
setUp(() => APIInitializer().initialize(api: MockAPI()));

tearDown(() => Injector().dispose());

test('Reset trading platform password', () async {
final TradingPlatformPasswordResetResponse passwordResetResponse =
await TradingPlatformPasswordResetResponseExtended.resetPassword(
request: const TradingPlatformPasswordResetRequest(
newPassword: 'Tst12345#',
platform: 'dxtrade',
verificationCode: 'VYt3xeeu',
),
);

expect(passwordResetResponse.tradingPlatformPasswordReset, true);
});
}

0 comments on commit 41892a3

Please sign in to comment.