71 lines
1.7 KiB
Dart
71 lines
1.7 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:hub/features/backend/index.dart';
|
|
import 'package:hub/features/menu/index.dart';
|
|
import 'package:hub/features/module/index.dart';
|
|
import 'package:hub/features/storage/index.dart';
|
|
import 'package:hub/initialization.dart';
|
|
|
|
import 'package:integration_test/integration_test.dart';
|
|
|
|
class ApiImpl implements Api {
|
|
@override
|
|
var getLicense = LicenseApi() as GetLicense;
|
|
}
|
|
|
|
class LicenseApi extends GetLicense {
|
|
@override
|
|
Future<ApiCallResponse> call() async => ApiCallResponse(
|
|
{
|
|
'error_msg': 'error',
|
|
},
|
|
{
|
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
},
|
|
200,
|
|
);
|
|
}
|
|
|
|
void main() {
|
|
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
|
|
|
setUpAll(() async {
|
|
await initializeBindings();
|
|
});
|
|
|
|
group('Test', () {
|
|
late LicenseRepository repo = LicenseRepositoryImpl(
|
|
DatabaseService.database,
|
|
ApiImpl(),
|
|
);
|
|
List<MenuEntry> menuEntries = MenuEntry.entries;
|
|
|
|
test('update license', () async {
|
|
late bool result;
|
|
result = await repo.updateLicense();
|
|
expect(result, true);
|
|
});
|
|
|
|
test('get module', () async {
|
|
late String? result;
|
|
for (var entry in menuEntries) {
|
|
result = await repo.getModule(entry.key);
|
|
expect(result, isNotNull);
|
|
}
|
|
});
|
|
|
|
test('set module', () async {
|
|
late bool? result;
|
|
for (var entry in menuEntries) {
|
|
result = await repo.setModule(entry.key, '');
|
|
expect(result, true);
|
|
}
|
|
});
|
|
|
|
test('clean license', () async {
|
|
late bool result;
|
|
result = await repo.cleanLicense();
|
|
expect(result, true);
|
|
});
|
|
});
|
|
}
|