Skip to content
This repository has been archived by the owner on Apr 25, 2022. It is now read-only.

Commit

Permalink
test(timetable): more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
CCXXXI committed Oct 23, 2021
1 parent a1aef19 commit 5bc1c29
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions test/timetable/ecnu/ecnu_logic_test.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
import 'package:dio/dio.dart';
import 'package:ecnu_timetable/timetable/ecnu/ecnu_logic.dart';
import 'package:ecnu_timetable/utils/database.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:get/get.dart' hide Response;
import 'package:hive_flutter/adapters.dart';

class FakeDio extends Fake implements Dio {
@override
Future<Response<T>> get<T>(
String path, {
Map<String, dynamic>? queryParameters,
Options? options,
CancelToken? cancelToken,
ProgressCallback? onReceiveProgress,
}) async {
await Future.delayed(const Duration(days: 1));

throw DioError(
requestOptions: RequestOptions(path: path),
);
}
}

void main() {
setUpAll(() async {
await initDatabase(clear: true);
Expand Down Expand Up @@ -78,6 +97,21 @@ void main() {
);
expect(courses.toMap().toString(), coursesResult);
});

test('years', () {
final logic = Get.put(EcnuLogic(dio: FakeDio()));

logic.year.value = 2021;
expect(logic.years, {
2019: '2019 - 2020',
2020: '2020 - 2021',
2021: '2021 - 2022',
2022: '2022 - 2023',
2023: '2023 - 2024',
});

Get.delete<EcnuLogic>();
});
}

const coursesJs = '''
Expand Down

0 comments on commit 5bc1c29

Please sign in to comment.