Skip to content

Commit

Permalink
test: add unit tests for new Ti.Geolocation constants/method
Browse files Browse the repository at this point in the history
  • Loading branch information
sgtcoolguy committed Sep 8, 2020
1 parent 43ce3fc commit 39ef241
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions tests/Resources/ti.geolocation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
/* globals OS_VERSION_MAJOR */
/* eslint-env mocha */
/* eslint no-unused-expressions: "off" */
'use strict';
Expand All @@ -13,6 +14,7 @@ var should = require('./utilities/assertions');
// Skip on Windows 10 Mobile device family due to prompt,
// however we might be able to run some tests?
describe.windowsBroken('Titanium.Geolocation', function () {

it('.apiName', function () {
should(Ti.Geolocation).have.readOnlyProperty('apiName').which.is.a.String();
should(Ti.Geolocation.apiName).be.eql('Ti.Geolocation');
Expand Down Expand Up @@ -244,7 +246,52 @@ describe.windowsBroken('Titanium.Geolocation', function () {
should(Ti.Geolocation.trackSignificantLocationChange).be.true();
});

it.ios('.ACCURACY_REDUCED', function () {
if (OS_VERSION_MAJOR >= 14) {
should(Ti.Geolocation).have.constant('ACCURACY_REDUCED').which.is.a.Number();
}
});

it.ios('.ACCURACY_AUTHORIZATION_FULL', function () {
if (OS_VERSION_MAJOR >= 14) {
should(Ti.Geolocation).have.constant('ACCURACY_AUTHORIZATION_FULL').which.is.a.Number();
}
});

it.ios('.ACCURACY_AUTHORIZATION_REDUCED', function () {
if (OS_VERSION_MAJOR >= 14) {
should(Ti.Geolocation).have.constant('ACCURACY_AUTHORIZATION_REDUCED').which.is.a.Number();
}
});

it.ios('.locationAccuracyAuthorization', function () {
if (OS_VERSION_MAJOR >= 14) {
should(Ti.Geolocation).have.a.property('locationAccuracyAuthorization').which.is.a.Number();
}
});

// Methods
it.ios('#requestTemporaryFullAccuracyAuthorization()', function (finish) {
this.timeout(6e4); // 60 sec
if (OS_VERSION_MAJOR < 14) {
return finish();
}

should(Ti.Geolocation.requestTemporaryFullAccuracyAuthorization).be.a.Function();
Ti.Geolocation.requestTemporaryFullAccuracyAuthorization('purposekey', function (e) {
try {
// It will always give error because 'purposekey' is not in tiapp.xml.
should(e).have.property('success').which.is.a.Boolean();
should(e.success).be.false();
should(e).have.property('code').which.is.a.Number();
should(e.code).be.eql(1);
should(e).have.property('error').which.is.a.String();
finish();
} catch (err) {
return finish(err);
}
});
});

it('#forwardGeocoder()', function (finish) {
this.timeout(6e4); // 60 sec
Expand Down

0 comments on commit 39ef241

Please sign in to comment.