49 lines
1.7 KiB
Dart
49 lines
1.7 KiB
Dart
|
|
// 功能描述:合同列表类型、会话隔离及真实状态回归;版本: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';
|
|||
|
|
|
|||
|
|
void main() {
|
|||
|
|
test('合同草稿保持真实状态并拦截跨会话迟到响应', () async {
|
|||
|
|
var token = 'first';
|
|||
|
|
var changeSession = false;
|
|||
|
|
final repo = ClientRepository(
|
|||
|
|
ApiClient(
|
|||
|
|
() => token,
|
|||
|
|
client: MockClient((request) async {
|
|||
|
|
expect(request.url.path.endsWith('/gas/contracts'), isTrue);
|
|||
|
|
if (changeSession) token = 'second';
|
|||
|
|
return http.Response(
|
|||
|
|
jsonEncode({
|
|||
|
|
'code': 0,
|
|||
|
|
'details': [
|
|||
|
|
{
|
|||
|
|
'identity': 'c1',
|
|||
|
|
'contract_no': 'HT1',
|
|||
|
|
'title': '合同',
|
|||
|
|
'terms': '条款',
|
|||
|
|
'contract_status': 0,
|
|||
|
|
'station_name': '气站',
|
|||
|
|
'has_attachment': false,
|
|||
|
|
'signed_at': '0001-01-01T00:00:00Z',
|
|||
|
|
},
|
|||
|
|
],
|
|||
|
|
}),
|
|||
|
|
200,
|
|||
|
|
headers: {'content-type': 'application/json; charset=utf-8'},
|
|||
|
|
);
|
|||
|
|
}),
|
|||
|
|
),
|
|||
|
|
);
|
|||
|
|
final contracts = await repo.gasContracts();
|
|||
|
|
expect(contracts.single.statusName, '草稿');
|
|||
|
|
expect(contracts.single.signedAt, isNull);
|
|||
|
|
expect(contracts.single.stationName, '气站');
|
|||
|
|
changeSession = true;
|
|||
|
|
await expectLater(repo.gasContracts(), throwsA(isA<SessionExpiredException>()));
|
|||
|
|
});
|
|||
|
|
}
|