已完成用户APP首期功能开发
交付用户端首期页面、配套接口、后台资源及测试文档。用户APP构建、静态分析和三个管理后台构建通过;完整测试仍有2项失败,后端模型注释检查未通过,详见交付记录。
This commit is contained in:
45
apps/user_app/test/data/recharge_agreement_test.dart
Normal file
45
apps/user_app/test/data/recharge_agreement_test.dart
Normal file
@@ -0,0 +1,45 @@
|
||||
// 功能描述:充值协议按实际版本提交并校验确认结果;版本:1.0.0。
|
||||
import 'dart:convert';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:http/testing.dart';
|
||||
import 'package:user_app/data/repositories/client_repository.dart';
|
||||
import 'package:user_app/data/services/api_client.dart';
|
||||
import 'package:user_app/domain/models/recharge.dart';
|
||||
import 'package:user_app/domain/models/client_models.dart';
|
||||
|
||||
class _Repo extends ClientRepository {
|
||||
_Repo(super.api);
|
||||
@override
|
||||
Future<UserProfile> profile() async =>
|
||||
const UserProfile(identity: 'alice', name: '', phone: '', avatar: '');
|
||||
}
|
||||
|
||||
void main() {
|
||||
test('确认使用稳定账号版本请求号,拒绝错误版本响应', () async {
|
||||
var version = 2;
|
||||
final repo = _Repo(
|
||||
ApiClient(
|
||||
() => 'token',
|
||||
client: MockClient((request) async {
|
||||
expect(request.method, 'POST');
|
||||
expect(request.url.path, '/heqi/client/v1/user/contents/read-confirmations');
|
||||
final body = jsonDecode(request.body) as Map;
|
||||
expect(body['content_version'], 2);
|
||||
expect(body['request_no'], 'consent:alice:agreement:2');
|
||||
return http.Response(
|
||||
jsonEncode({
|
||||
'code': 0,
|
||||
'details': {'identity': 'read', 'content_version': version},
|
||||
}),
|
||||
200,
|
||||
);
|
||||
}),
|
||||
),
|
||||
);
|
||||
const agreement = RechargeAgreement('agreement', 2, '充值协议', '正文');
|
||||
await repo.confirmRechargeAgreement(agreement);
|
||||
version = 3;
|
||||
await expectLater(repo.confirmRechargeAgreement(agreement), throwsA(isA<ApiException>()));
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user