-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
unit_test.dart
50 lines (47 loc) · 1.44 KB
/
unit_test.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:npm/features/package_details/package_details.dart';
import 'package:npm/features/packages/packages.dart';
import 'package:test/test.dart';
import 'fake_package_details.dart';
import 'fake_packages.dart';
import 'util.dart';
void main() {
group('[Unit Test]', () {
test('getPackages()', () async {
final container = createContainer(
overrides: [
packagesProvider(search: fakePackagesName)
.overrideWith(fakePackagesProvider),
],
);
expect(
container.read(packagesProvider(search: fakePackagesName)),
const AsyncLoading<List<Package>>(),
);
final packages = await container
.read(packagesProvider(search: fakePackagesName).future);
expect(
packages,
fakePackages,
);
});
test('getPackageDetails()', () async {
final container = createContainer(
overrides: [
packageDetailsProvider(id: fakePackageDetailsName)
.overrideWith(fakePackageDetailsProvider),
],
);
expect(
container.read(packageDetailsProvider(id: fakePackageDetailsName)),
const AsyncLoading<PackageDetails>(),
);
final packageDetails = await container
.read(packageDetailsProvider(id: fakePackageDetailsName).future);
expect(
packageDetails,
fakePackageDetails,
);
});
});
}