-
Notifications
You must be signed in to change notification settings - Fork 16
/
override_test.dart
46 lines (40 loc) · 1.17 KB
/
override_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
import 'package:test/test.dart';
import 'package:mockito/mockito.dart';
import 'package:typesense/src/override.dart';
import 'test_utils.mocks.dart';
void main() {
group('Override', () {
late Override override;
late MockApiCall mock;
setUp(() {
mock = MockApiCall();
override = Override(
'companies',
'customize-apple',
mock,
);
});
test('delete() calls ApiCall.delete()', () async {
when(
mock.delete(
'/collections/companies/overrides/customize-apple',
),
).thenAnswer((realInvocation) => Future.value({"id": "customize-apple"}));
expect(await override.delete(), equals({"id": "customize-apple"}));
});
test('retrieve() calls ApiCall.get()', () async {
final overrideMap = {
"id": "customize-apple",
"company_name": "Stark Industries",
"num_employees": 5215,
"country": "USA"
};
when(
mock.get(
'/collections/companies/overrides/customize-apple',
),
).thenAnswer((realInvocation) => Future.value(overrideMap));
expect(await override.retrieve(), equals(overrideMap));
});
});
}