53 lines
1.5 KiB
Dart
53 lines
1.5 KiB
Dart
// Author: fruit.com.cn
|
|
|
|
import 'dart:convert';
|
|
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:fruitshorts/core/data/remote/api_client.dart';
|
|
import 'package:fruitshorts/core/data/remote/notice_api.dart';
|
|
|
|
import '../support/fake_http_adapter.dart';
|
|
|
|
void main() {
|
|
test('should_parse_notice_page_with_string_ids_when_requested', () async {
|
|
final adapter = FakeHttpAdapter(
|
|
(_) async => FakeHttpResponse(
|
|
jsonEncode({
|
|
'code': 0,
|
|
'message': 'ok',
|
|
'data': {
|
|
'total': '3',
|
|
'list': [
|
|
{
|
|
'id': '2111012753262120962',
|
|
'title': 'Maintenance',
|
|
'content': 'Line one\nLine two',
|
|
'type': 'SYSTEM',
|
|
'publishAt': '2026-10-17T12:30:00',
|
|
'expireAt': null,
|
|
},
|
|
],
|
|
},
|
|
}),
|
|
),
|
|
);
|
|
final api = NoticeApi(
|
|
ApiClient(baseUrl: 'http://127.0.0.1:8081', adapter: adapter),
|
|
);
|
|
|
|
final page = await api.page(pageIndex: 2, pageSize: 20);
|
|
|
|
expect(adapter.requests.single.uri.path, '/app/notices');
|
|
expect(adapter.requests.single.queryParameters, {
|
|
'pageIndex': '2',
|
|
'pageSize': '20',
|
|
});
|
|
expect(page.total, 3);
|
|
expect(page.notices.single.id, '2111012753262120962');
|
|
expect(page.notices.single.content, 'Line one\nLine two');
|
|
expect(page.notices.single.type, 'SYSTEM');
|
|
expect(page.notices.single.publishAt, DateTime(2026, 10, 17, 12, 30));
|
|
expect(page.notices.single.expireAt, isNull);
|
|
});
|
|
}
|