-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bdda626
commit 3bae9af
Showing
3 changed files
with
137 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{pkgs}: { | ||
channel = "stable-23.11"; | ||
packages = [ | ||
pkgs.nodePackages.firebase-tools | ||
pkgs.jdk17 | ||
pkgs.unzip | ||
]; | ||
idx.extensions = [ | ||
|
||
]; | ||
idx.previews = { | ||
previews = { | ||
web = { | ||
command = [ | ||
"flutter" | ||
"run" | ||
"--machine" | ||
"-d" | ||
"web-server" | ||
"--web-hostname" | ||
"0.0.0.0" | ||
"--web-port" | ||
"$PORT" | ||
]; | ||
manager = "flutter"; | ||
}; | ||
android = { | ||
command = [ | ||
"flutter" | ||
"run" | ||
"--machine" | ||
"-d" | ||
"android" | ||
"-d" | ||
"emulator-5554" | ||
]; | ||
manager = "flutter"; | ||
}; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,95 @@ | ||
import 'package:batucadapp/features/schools/school.dart'; | ||
import 'package:batucadapp/features/schools/schools_repo.dart'; | ||
import 'package:batucadapp/utils/immutable_list.dart'; | ||
import 'package:dio/dio.dart'; | ||
import 'package:fast_immutable_collections/fast_immutable_collections.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:mocktail/mocktail.dart'; | ||
|
||
import '../../create_container.dart'; | ||
|
||
class SchoolsRepoMock with Mock implements SchoolsRepoImpls {} | ||
|
||
void main() { | ||
group('Schools Repository', () { | ||
test( | ||
''' | ||
When SchoolsRepo is called | ||
Should return a instance of SchoolsRepoImpls | ||
''', | ||
() { | ||
final mock = SchoolsRepoMock(); | ||
final container = createContainer( | ||
overrides: [schoolsRepoProvider.overrideWith((_) => mock)], | ||
); | ||
|
||
expect( | ||
container.read(schoolsRepoProvider), | ||
isA<SchoolsRepoImpls>(), | ||
); | ||
}, | ||
); | ||
|
||
test(''' | ||
When SchoolsRepo.getSchools is called | ||
Should return a list of Schools | ||
''', () async { | ||
const page = 1; | ||
const pageSize = 10; | ||
final mock = SchoolsRepoMock(); | ||
when( | ||
() => mock.getSchools( | ||
page: any(named: 'page'), | ||
pageSize: any(named: 'pageSize'), | ||
sort: any(named: 'sort'), | ||
search: any(named: 'search'), | ||
), | ||
).thenAnswer((_) async => <School>[].lock); | ||
|
||
final container = createContainer( | ||
overrides: [schoolsRepoProvider.overrideWith((_) => mock)], | ||
); | ||
|
||
expect( | ||
await container.read(schoolsRepoProvider).getSchools( | ||
page: page, | ||
pageSize: pageSize, | ||
sort: 'name', | ||
search: '', | ||
), | ||
isA<ImmutableList<School>>(), | ||
); | ||
}); | ||
|
||
test(''' | ||
When SchoolsRepo.getSchools is called | ||
Should throw an error | ||
''', () async { | ||
const page = 1; | ||
const pageSize = 10; | ||
final mock = SchoolsRepoMock(); | ||
when( | ||
() => mock.getSchools( | ||
page: any(named: 'page'), | ||
pageSize: any(named: 'pageSize'), | ||
sort: any(named: 'sort'), | ||
search: any(named: 'search'), | ||
), | ||
).thenThrow(DioException(requestOptions: RequestOptions())); | ||
|
||
final container = createContainer( | ||
overrides: [schoolsRepoProvider.overrideWith((_) => mock)], | ||
); | ||
|
||
expect( | ||
() => container.read(schoolsRepoProvider).getSchools( | ||
page: page, | ||
pageSize: pageSize, | ||
sort: 'name', | ||
search: '', | ||
), | ||
throwsA(isA<DioException>()), | ||
); | ||
}); | ||
}); | ||
} |