Update: geocoder test & snapshot
MODIFY
package.json
package.json
],
"scripts": {
"test": "jest && npm run eslint",
+ "jest": "jest",
"test:watch": "jest --watch",
"eslint": "node node_modules/eslint/bin/eslint www && node node_modules/eslint/bin/eslint src",
"test:android": "cordova-paramedic --cleanUpAfterRun --verbose --platform android --plugin '. --variable API_KEY_FOR_ANDROID=test' --useTunnel",

MODIFY
www/__test__/Geocoder.spec.js
www/__test__/Geocoder.spec.js
@@ -21,7 +21,7 @@ describe('Geocode', () => {
expect(geocoder.geocode).toBeDefined();
});
- fit('should return a promise if a callback is not passed', async () => {
+ it('should return a promise if a callback is not passed', async () => {
const request = {
address: '',
};
@@ -82,8 +82,39 @@ describe('Geocode', () => {
});
});
- xdescribe('multiple requests', () => {
- // todo
+
+
+ describe('multiple request', () => {
+ describe('position', () => {
+ it('should call the native plugin with the correct parameters', () => {
+ geocoder.geocode({
+ position: [
+ {
+ lat: 0,
+ lng: 0,
+ },
+ {
+ lat: 1,
+ lng: 1,
+ },
+ ]
});
+ expect(execSpy.mock.calls).toMatchSnapshot();
+ });
+ });
+
+ describe('address1', () => {
+ it('should call the native plugin with the correct parameters', () => {
+ geocoder.geocode({
+ address: [
+ 'Tokyo, Japan',
+ 'Kyoto, Japan',
+ ]
+ });
+ expect(execSpy.mock.calls).toMatchSnapshot();
+ });
+ });
+ });
+
});
});

MODIFY
www/__test__/__snapshots__/Geocoder.spec.js.snap
www/__test__/__snapshots__/Geocoder.spec.js.snap
// Jest Snapshot v1, https://goo.gl/fbAQLP
+exports[`Geocode geocode() multiple request address1 should call the native plugin with the correct parameters 1`] = `
+Array [
+ Array [
+ [Function],
+ [Function],
+ "PluginGeocoder",
+ "geocode",
+ Array [
+ Object {
+ "address": "Tokyo, Japan",
+ "idx": 0,
+ },
+ ],
+ ],
+ Array [
+ [Function],
+ [Function],
+ "PluginGeocoder",
+ "geocode",
+ Array [
+ Object {
+ "address": "Kyoto, Japan",
+ "idx": 1,
+ },
+ ],
+ ],
+]
+`;
+
+exports[`Geocode geocode() multiple request position should call the native plugin with the correct parameters 1`] = `
+Array [
+ Array [
+ [Function],
+ [Function],
+ "PluginGeocoder",
+ "geocode",
+ Array [
+ Object {
+ "idx": 0,
+ "position": Object {
+ "lat": 0,
+ "lng": 0,
+ },
+ },
+ ],
+ ],
+ Array [
+ [Function],
+ [Function],
+ "PluginGeocoder",
+ "geocode",
+ Array [
+ Object {
+ "idx": 1,
+ "position": Object {
+ "lat": 1,
+ "lng": 1,
+ },
+ },
+ ],
+ ],
+]
+`;
+
exports[`Geocode geocode() should call the if both position and address options are provided 1`] = `[Error: Invalid request]`;
exports[`Geocode geocode() should error if both position and address options are provided 1`] = `[Error: Invalid request]`;

Update: geocoder test & snapshot