Skip to content

Commit 2c15d11

Browse files
committed
test: update unit test with snapshots
1 parent 59f6272 commit 2c15d11

File tree

2 files changed

+96
-9
lines changed

2 files changed

+96
-9
lines changed
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`geocode address should call googleApi function with address and bounds 1`] = `
4+
[MockFunction] {
5+
"calls": Array [
6+
Array [
7+
"TEST",
8+
"London",
9+
Object {
10+
"ne": Object {
11+
"lat": 60,
12+
"lng": 10,
13+
},
14+
"sw": Object {
15+
"lat": 40,
16+
"lng": -20,
17+
},
18+
},
19+
"en",
20+
undefined,
21+
],
22+
],
23+
"results": Array [
24+
Object {
25+
"type": "return",
26+
"value": undefined,
27+
},
28+
],
29+
}
30+
`;
31+
32+
exports[`geocode address should call googleApi function with address if fallbackToGoogle is set and native fails 1`] = `
33+
[MockFunction] {
34+
"calls": Array [
35+
Array [
36+
"TEST",
37+
"London",
38+
"en",
39+
undefined,
40+
],
41+
],
42+
"results": Array [
43+
Object {
44+
"type": "return",
45+
"value": undefined,
46+
},
47+
],
48+
}
49+
`;
50+
51+
exports[`geocode position should call googleApi function with position if fallbackToGoogle is set and native fails 1`] = `
52+
[MockFunction] {
53+
"calls": Array [
54+
Array [
55+
"TEST",
56+
Object {
57+
"lat": -1.2,
58+
"lng": 3.4,
59+
},
60+
"de",
61+
undefined,
62+
],
63+
],
64+
"results": Array [
65+
Object {
66+
"type": "return",
67+
"value": undefined,
68+
},
69+
],
70+
}
71+
`;
72+
73+
exports[`geocode position should call native function with position 1`] = `
74+
[MockFunction] {
75+
"calls": Array [
76+
Array [
77+
Object {
78+
"lat": -1.2,
79+
"lng": 3.4,
80+
},
81+
"en",
82+
5,
83+
],
84+
],
85+
"results": Array [
86+
Object {
87+
"type": "return",
88+
"value": undefined,
89+
},
90+
],
91+
}
92+
`;

src/__tests__/geocoder.test.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe('geocode position', () => {
2424
it('should call native function with position', async () => {
2525
let position = { lat: -1.2, lng: 3.4 };
2626
await geocoder.geocodePosition(position);
27-
expect(nativeImpl.geocodePosition).toBeCalledWith(position, 'en', 5);
27+
expect(nativeImpl.geocodePosition).toMatchSnapshot();
2828
});
2929

3030
it('should throw if native function rejects and fallbackToGoogle is not set', async () => {
@@ -42,7 +42,7 @@ describe('geocode position', () => {
4242
locale: 'de',
4343
};
4444
await geocoder.geocodePosition(position, options);
45-
expect(googleApi.geocodePosition).toBeCalledWith('TEST', position, 'de');
45+
expect(googleApi.geocodePosition).toMatchSnapshot();
4646
});
4747
});
4848

@@ -69,7 +69,7 @@ describe('geocode address', () => {
6969
locale: 'en',
7070
};
7171
await geocoder.geocodeAddress(address, options);
72-
expect(googleApi.geocodeAddress).toBeCalledWith('TEST', address, 'en');
72+
expect(googleApi.geocodeAddress).toMatchSnapshot();
7373
});
7474

7575
it('should call googleApi function with address and bounds', async () => {
@@ -83,11 +83,6 @@ describe('geocode address', () => {
8383
bounds,
8484
};
8585
await geocoder.geocodeAddress(address, options);
86-
expect(googleApi.geocodeAddressWithBounds).toBeCalledWith(
87-
'TEST',
88-
address,
89-
bounds,
90-
'en'
91-
);
86+
expect(googleApi.geocodeAddressWithBounds).toMatchSnapshot();
9287
});
9388
});

0 commit comments

Comments
 (0)