feat(client): invite api + provider + auth_api.register 加 inviteCode
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:http/testing.dart';
|
||||
import 'package:pangolin_vpn/services/api_client.dart';
|
||||
import 'package:pangolin_vpn/services/invite_api.dart';
|
||||
|
||||
ApiClient _c(MockClient m) => ApiClient(baseUrl: 'http://x', getToken: () => 't', refresh: () async => false, client: m);
|
||||
|
||||
void main() {
|
||||
test('fetch 解析邀请信息 + TG 任务态', () async {
|
||||
final api = InviteApi(_c(MockClient((req) async {
|
||||
expect(req.url.path, '/v1/invite');
|
||||
return http.Response('{"invite_code":"ABCD2345","invite_link":"https://x/i/ABCD2345",'
|
||||
'"invited":3,"converted":1,"earned_days":16,'
|
||||
'"telegram":{"enabled":true,"joined":false,"channel":"@pangolin_app"}}', 200);
|
||||
})));
|
||||
final info = await api.fetch();
|
||||
expect(info.code, 'ABCD2345');
|
||||
expect(info.invited, 3);
|
||||
expect(info.earnedDays, 16);
|
||||
expect(info.tgEnabled, true);
|
||||
expect(info.tgJoined, false);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user