This repository has been archived by the owner on Sep 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 180
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
Showing
6 changed files
with
125 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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
e2e/GeocoderE2EApp | ||
|
||
# OSX | ||
# | ||
.DS_Store | ||
|
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,5 +1,7 @@ | ||
img | ||
example | ||
e2e | ||
test | ||
|
||
# OSX | ||
# | ||
|
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
require('babel-core/register')({ | ||
presets: ["react-native"] | ||
}); | ||
require("babel-polyfill"); | ||
|
||
require('colors'); | ||
|
||
process.on('unhandledRejection', function(reason, p) { | ||
throw new Error(reason); | ||
}); |
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,14 @@ | ||
"use strict"; | ||
|
||
exports.configure = function (driver) { | ||
// See whats going on | ||
driver.on('status', function (info) { | ||
console.log(info.cyan); | ||
}); | ||
driver.on('command', function (meth, path, data) { | ||
console.log(' > ' + meth.yellow, path.grey, data || ''); | ||
}); | ||
driver.on('http', function (meth, path, data) { | ||
console.log(' > ' + meth.magenta, path, (data || '').grey); | ||
}); | ||
}; |
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,84 @@ | ||
import wd from 'wd'; | ||
import path from 'path'; | ||
import { expect } from 'chai'; | ||
|
||
const London = { | ||
lat: 51.50853, | ||
lng: -0.12574, | ||
}; | ||
|
||
const Paris = { | ||
lat: 48.85341, | ||
lng: 2.3488, | ||
}; | ||
|
||
describe ('react-native-geocoder', function() { | ||
this.timeout(600000); | ||
|
||
let driver; | ||
|
||
before(() => { | ||
driver = wd.promiseChainRemote({ | ||
host: 'localhost', | ||
port: 4723 | ||
}); | ||
require("./helpers/logging").configure(driver); | ||
|
||
return driver | ||
.init({ | ||
platformName: 'Android', | ||
deviceName: 'Android Emulator', | ||
newCommandTimeout: 60000, | ||
app: path.resolve('e2e/GeocoderE2EApp/android/app/build/outputs/apk/app-debug.apk') | ||
}) | ||
.setImplicitWaitTimeout(3000); | ||
// .waitForElementByXPath('//android.widget.Button[@text="Reload JS"]'). | ||
// then((elem) => { | ||
// elem.click(); | ||
// }, (err) => { | ||
// ignoring if Reload JS button can't be located | ||
// }) | ||
}); | ||
|
||
after(() => { | ||
return driver.quit(); | ||
}); | ||
|
||
|
||
it ('displays default view', async () => { | ||
await driver.waitForElementByXPath('//android.widget.EditText[1]', 30000); // wait for view to be initialized | ||
await driver.waitForElementByXPath('//android.widget.EditText[2]'); | ||
await driver.waitForElementByXPath('//android.widget.TextView[starts-with(@text, "Geocode")]'); | ||
await driver.waitForElementByXPath('//android.widget.TextView[starts-with(@text, "Reverse")]'); | ||
}); | ||
|
||
it ('geocodes address', async () => { | ||
await driver.waitForElementByXPath('//android.widget.EditText[1]').sendKeys("London"); | ||
await driver.waitForElementByXPath('//android.widget.TextView[starts-with(@text, "Geocode")]').click().click(); | ||
|
||
const locality = await driver.waitForElementByXPath('//android.widget.TextView[starts-with(@text, "Locality")]', 5000).text(); | ||
expect(locality.split(':')[1].trim().toLowerCase()).to.contain('london'); | ||
|
||
const latlng = await driver.waitForElementByXPath('//android.widget.TextView[starts-with(@text, "LatLng")]').text(); | ||
const [lat, lng] = latlng.split(':')[1].split(',').map(v => 1 * v.trim()); | ||
|
||
expect(lat - London.lat).to.be.below(0.001); | ||
expect(lng - London.lng).to.be.below(0.001); | ||
}); | ||
|
||
it ('geocodes lat lng into address', async () => { | ||
await driver.waitForElementByXPath('//android.widget.EditText[2]').sendKeys(`${Paris.lat} ${Paris.lng}`); | ||
await driver.waitForElementByXPath('//android.widget.TextView[starts-with(@text, "Reverse")]').click().click(); | ||
|
||
const locality = await driver.waitForElementByXPath('//android.widget.TextView[starts-with(@text, "Locality")]', 5000).text(); | ||
expect(locality.split(':')[1].trim().toLowerCase()).to.contain('paris'); | ||
|
||
const latlng = await driver.waitForElementByXPath('//android.widget.TextView[starts-with(@text, "LatLng")]').text(); | ||
const [lat, lng] = latlng.split(':')[1].split(',').map(v => 1 * v.trim()); | ||
|
||
expect(lat - Paris.lat).to.be.below(0.001); | ||
expect(lng - Paris.lng).to.be.below(0.001); | ||
}); | ||
|
||
}); | ||
|