Closed Presheda closed 3 years ago
Please provide a reproduction code
Steps to reproduce
SplashScreenController
import 'package:deggia_regular/ui/route/route_names.dart';
import 'package:deggia_regular/ui/views/home/home_screen.dart';
import 'package:deggia_regular/utils/locator.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
class SplashScreenController extends GetxController {
StorageService storageService = locator<StorageService>();
@override
void onInit() {
super.onInit();
fetchData();
}
Future fetchData() async {
Get.testMode = true;
bool isFirstTime = await storageService.firstTime();
if (isFirstTime) {
await storageService.setFirstTime();
await Get.offAndToNamed(RouteName.on_boarding);
} else {
await Get.offAllNamed(RouteName.homepage);
}
}
}
group("first_time_load", () {
setUp(() {
var service = StorageServiceMock();
when(service.firstTime()).thenAnswer((realInvocation) async => true);
when(service.isLightMode()).thenAnswer((realInvocation) async => true);
locator.registerFactory<StorageService>(() => service);
});
test("test description", () async {
SplashScreenController controller = SplashScreenController();
await controller.fetchData();
});
}
)
unable to run navigation test as Get.testMode is ineffective
` test("test description", () async {
`