Skip to content

Commit

Permalink
fix: ✅ fix mocking for new version
Browse files Browse the repository at this point in the history
  • Loading branch information
Tokenyet committed Jun 4, 2022
1 parent 5a171b6 commit cabd318
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ void main() {
});

test('throws DioError by wrong github fetching', () async {
when(() => dio.get(captureAny()))
when(() => dio.get<String>(captureAny()))
.thenThrow(DioError(requestOptions: RequestOptions(path: '')));
expect(
() => repository.hasGreaterVersion(version: '1.2.3'),
throwsA(isA<DioError>()),
);

expect(
verify(() => dio.get(captureAny())).captured,
verify(() => dio.get<String>(captureAny())).captured,
[
'https://raw.githubusercontent.com/MinecraftCube/MinecraftCubeDesktop/version_info/version'
],
Expand All @@ -51,7 +51,7 @@ void main() {

test('return false when data is null', () async {
final Response<String> response = MockResponse<String>();
when(() => dio.get(any())).thenAnswer((_) async => response);
when(() => dio.get<String>(any())).thenAnswer((_) async => response);
when(() => response.data).thenReturn(null);

expect(
Expand All @@ -62,7 +62,7 @@ void main() {

test('throws FormatException by unexpected online version', () async {
final Response<String> response = MockResponse<String>();
when(() => dio.get(any())).thenAnswer((_) async => response);
when(() => dio.get<String>(any())).thenAnswer((_) async => response);
when(() => response.data).thenReturn('sakjdasksaj');

expect(
Expand All @@ -74,7 +74,7 @@ void main() {
test('return true when online version is greater than app version',
() async {
final Response<String> response = MockResponse<String>();
when(() => dio.get(any())).thenAnswer((_) async => response);
when(() => dio.get<String>(any())).thenAnswer((_) async => response);
when(() => response.data).thenReturn('1.2.4');

expect(
Expand All @@ -88,7 +88,7 @@ void main() {
test(
'throws DioError when there is no release note for specified country&lang.',
() {
when(() => dio.get(captureAny()))
when(() => dio.get<String>(captureAny()))
.thenThrow(DioError(requestOptions: RequestOptions(path: '')));
expect(
() => repository.getLatestRelease(fullLocale: 'test'),
Expand All @@ -101,7 +101,7 @@ void main() {
'return null',
() async {
final Response<String> response = MockResponse<String>();
when(() => dio.get(any())).thenAnswer((_) async => response);
when(() => dio.get<String>(any())).thenAnswer((_) async => response);
when(() => response.data).thenReturn(null);
expect(
await repository.getLatestRelease(fullLocale: 'test'),
Expand All @@ -114,7 +114,7 @@ void main() {
'return content',
() async {
final Response<String> response = MockResponse<String>();
when(() => dio.get(any())).thenAnswer((_) async => response);
when(() => dio.get<String>(any())).thenAnswer((_) async => response);
when(() => response.data).thenReturn('markdownContent');
expect(
await repository.getLatestRelease(fullLocale: 'test'),
Expand Down

0 comments on commit cabd318

Please sign in to comment.