|
| 1 | +import 'package:deriv_dependency_injector/dependency_injector.dart'; |
| 2 | +import 'package:flutter_deriv_api/api/api_initializer.dart'; |
| 3 | +import 'package:flutter_deriv_api/api/response/financial_assessment_questions_response_result.dart'; |
| 4 | +import 'package:flutter_deriv_api/api/response/financial_assessment_questions_response_result_extended.dart'; |
| 5 | +import 'package:flutter_deriv_api/basic_api/generated/financial_assessment_questions_send.dart'; |
| 6 | +import 'package:flutter_deriv_api/services/connection/api_manager/mock_api.dart'; |
| 7 | +import 'package:test/test.dart'; |
| 8 | + |
| 9 | +void main() { |
| 10 | + setUp(() => APIInitializer().initialize(api: MockAPI())); |
| 11 | + |
| 12 | + tearDown(() => Injector().dispose()); |
| 13 | + |
| 14 | + group( |
| 15 | + 'Financial Assessment Questions Group -> ', |
| 16 | + () { |
| 17 | + test( |
| 18 | + 'Fetch Financial Assessment Questions', |
| 19 | + () async { |
| 20 | + final FinancialAssessmentQuestionsResponseModel |
| 21 | + financialAssessmentQuestions = |
| 22 | + await FinancialAssessmentQuestionsResponseExtended() |
| 23 | + .fetchFinancialAssessmentQuestions( |
| 24 | + request: const FinancialAssessmentQuestionsRequest( |
| 25 | + version: 'v1')); |
| 26 | + |
| 27 | + final FinancialAssessmentQuestions? faQuestions = |
| 28 | + financialAssessmentQuestions.financialAssessmentQuestions; |
| 29 | + |
| 30 | + // expect( |
| 31 | + // faQuestions?.questions?['account_turnover'], |
| 32 | + // const QuestionsProperty( |
| 33 | + // answers: [ |
| 34 | + // AnswersItem( |
| 35 | + // hideIf: [], |
| 36 | + // key: 'less_than_25000', |
| 37 | + // value: 'Less than \$25,000', |
| 38 | + // ), |
| 39 | + // ], |
| 40 | + // hideIf: [], |
| 41 | + // question: 'Anticipated annual turnover', |
| 42 | + // type: TypeEnum.singleChoice, |
| 43 | + // ), |
| 44 | + // ); |
| 45 | + // expect( |
| 46 | + // faQuestions?.questions?['education_level'], |
| 47 | + // const QuestionsProperty( |
| 48 | + // answers: [ |
| 49 | + // AnswersItem( |
| 50 | + // hideIf: [], |
| 51 | + // key: 'primary', |
| 52 | + // value: 'Primary', |
| 53 | + // nextNode: 'net_income'), |
| 54 | + // ], |
| 55 | + // hideIf: [], |
| 56 | + // question: 'Education level', |
| 57 | + // type: TypeEnum.singleChoice, |
| 58 | + // ), |
| 59 | + // ); |
| 60 | + |
| 61 | + expect( |
| 62 | + faQuestions?.questions?['account_turnover'], |
| 63 | + const QuestionsProperty( |
| 64 | + answers: [ |
| 65 | + AnswersItem( |
| 66 | + hideIf: [], |
| 67 | + key: 'less_than_25000', |
| 68 | + value: 'Less than \$25,000', |
| 69 | + ), |
| 70 | + ], |
| 71 | + hideIf: [], |
| 72 | + question: 'Anticipated annual turnover', |
| 73 | + type: TypeEnum.singleChoice, |
| 74 | + ), |
| 75 | + ); |
| 76 | + |
| 77 | + expect( |
| 78 | + faQuestions?.questions?['education_level'], |
| 79 | + const QuestionsProperty( |
| 80 | + answers: [ |
| 81 | + AnswersItem( |
| 82 | + hideIf: [], |
| 83 | + key: 'primary', |
| 84 | + value: 'Primary', |
| 85 | + nextNode: 'net_income', |
| 86 | + ), |
| 87 | + ], |
| 88 | + hideIf: [], |
| 89 | + question: 'Education level', |
| 90 | + type: TypeEnum.singleChoice, |
| 91 | + ), |
| 92 | + ); |
| 93 | + |
| 94 | + expect( |
| 95 | + faQuestions?.questions?['employment_industry'], |
| 96 | + const QuestionsProperty( |
| 97 | + answers: [ |
| 98 | + AnswersItem( |
| 99 | + hideIf: [], |
| 100 | + key: 'construction', |
| 101 | + value: 'Construction', |
| 102 | + nextNode: 'occupation', |
| 103 | + ), |
| 104 | + ], |
| 105 | + hideIf: [], |
| 106 | + question: 'Industry of employment', |
| 107 | + type: TypeEnum.singleChoice, |
| 108 | + ), |
| 109 | + ); |
| 110 | + |
| 111 | + expect( |
| 112 | + faQuestions?.questions?['employment_status'], |
| 113 | + const QuestionsProperty( |
| 114 | + answers: [ |
| 115 | + AnswersItem( |
| 116 | + hideIf: [], |
| 117 | + key: 'employed', |
| 118 | + value: 'Employed', |
| 119 | + nextNode: 'employment_industry', |
| 120 | + ), |
| 121 | + ], |
| 122 | + hideIf: [], |
| 123 | + question: 'Employment status', |
| 124 | + type: TypeEnum.singleChoice, |
| 125 | + ), |
| 126 | + ); |
| 127 | + |
| 128 | + expect( |
| 129 | + faQuestions?.questions?['estimated_worth'], |
| 130 | + const QuestionsProperty( |
| 131 | + answers: [ |
| 132 | + AnswersItem( |
| 133 | + hideIf: [], |
| 134 | + key: 'less_than_100000', |
| 135 | + value: 'Less than \$100,000', |
| 136 | + nextNode: 'account_turnover', |
| 137 | + ), |
| 138 | + ], |
| 139 | + hideIf: [], |
| 140 | + question: 'Estimated net worth', |
| 141 | + type: TypeEnum.singleChoice, |
| 142 | + ), |
| 143 | + ); |
| 144 | + |
| 145 | + expect( |
| 146 | + faQuestions?.questions?['income_source'], |
| 147 | + const QuestionsProperty( |
| 148 | + answers: [ |
| 149 | + AnswersItem( |
| 150 | + hideIf: [], |
| 151 | + key: 'salaried_employee', |
| 152 | + value: 'Salaried Employee', |
| 153 | + nextNode: 'source_of_wealth', |
| 154 | + ), |
| 155 | + ], |
| 156 | + hideIf: [], |
| 157 | + question: 'Source of income', |
| 158 | + type: TypeEnum.singleChoice, |
| 159 | + ), |
| 160 | + ); |
| 161 | + |
| 162 | + expect( |
| 163 | + faQuestions?.questions?['net_income'], |
| 164 | + const QuestionsProperty( |
| 165 | + answers: [ |
| 166 | + AnswersItem( |
| 167 | + hideIf: [], |
| 168 | + key: 'less_than_25000', |
| 169 | + value: 'Less than \$25,000', |
| 170 | + nextNode: 'estimated_worth', |
| 171 | + ), |
| 172 | + ], |
| 173 | + hideIf: [], |
| 174 | + question: 'Net annual income', |
| 175 | + type: TypeEnum.singleChoice, |
| 176 | + ), |
| 177 | + ); |
| 178 | + |
| 179 | + expect( |
| 180 | + faQuestions?.questions?['occupation'], |
| 181 | + const QuestionsProperty( |
| 182 | + answers: [ |
| 183 | + AnswersItem( |
| 184 | + hideIf: [], |
| 185 | + key: 'chief_executives', |
| 186 | + value: 'Chief Executives, Senior Officials and Legislators', |
| 187 | + nextNode: 'income_source', |
| 188 | + ), |
| 189 | + ], |
| 190 | + hideIf: [], |
| 191 | + question: 'Occupation', |
| 192 | + type: TypeEnum.singleChoice, |
| 193 | + ), |
| 194 | + ); |
| 195 | + |
| 196 | + expect( |
| 197 | + faQuestions?.questions?['source_of_wealth'], |
| 198 | + const QuestionsProperty( |
| 199 | + answers: [ |
| 200 | + AnswersItem( |
| 201 | + hideIf: [], |
| 202 | + key: 'income_savings', |
| 203 | + value: 'Accumulation of Income/Savings', |
| 204 | + nextNode: 'education_level', |
| 205 | + ), |
| 206 | + ], |
| 207 | + hideIf: [], |
| 208 | + question: 'Source of Wealth', |
| 209 | + type: TypeEnum.singleChoice, |
| 210 | + ), |
| 211 | + ); |
| 212 | + }, |
| 213 | + ); |
| 214 | + }, |
| 215 | + ); |
| 216 | +} |
0 commit comments