Allow forced utilDetect(), useful for testing

This commit is contained in:
Bryan Housel
2016-10-18 21:56:24 -04:00
parent efd9e6df4b
commit 1d03414b80
3 changed files with 8 additions and 2 deletions
+2 -2
View File
@@ -3,8 +3,8 @@ import { utilStringQs } from './index';
var detected;
export function utilDetect() {
if (detected) return detected;
export function utilDetect(force) {
if (detected && !force) return detected;
detected = {};
var ua = navigator.userAgent,
+2
View File
@@ -358,11 +358,13 @@ describe('iD.serviceMapillary', function() {
describe('#signsSupported', function() {
it('returns false for Internet Explorer', function() {
ua = 'Trident/7.0; rv:11.0';
iD.Detect(true); // force redetection
expect(mapillary.signsSupported()).to.be.false;
});
it('returns false for Safari', function() {
ua = 'Version/9.1 Safari/601';
iD.Detect(true); // force redetection
expect(mapillary.signsSupported()).to.be.false;
});
});
+4
View File
@@ -28,11 +28,13 @@ describe('iD.uiCmd', function () {
it('does not overwrite mac keybindings', function () {
ua = 'Mac';
iD.Detect(true); // force redetection
expect(iD.uiCmd('⌘A')).to.eql('⌘A');
});
it('changes keys to linux versions', function () {
ua = 'Linux';
iD.Detect(true); // force redetection
expect(iD.uiCmd('⌘A')).to.eql('Ctrl+A');
expect(iD.uiCmd('⇧A')).to.eql('Shift+A');
expect(iD.uiCmd('⌘⇧A')).to.eql('Ctrl+Shift+A');
@@ -41,6 +43,7 @@ describe('iD.uiCmd', function () {
it('changes keys to win versions', function () {
ua = 'Win';
iD.Detect(true); // force redetection
expect(iD.uiCmd('⌘A')).to.eql('Ctrl+A');
expect(iD.uiCmd('⇧A')).to.eql('Shift+A');
expect(iD.uiCmd('⌘⇧A')).to.eql('Ctrl+Shift+A');
@@ -49,6 +52,7 @@ describe('iD.uiCmd', function () {
it('handles multi-character keys', function () {
ua = 'Win';
iD.Detect(true); // force redetection
expect(iD.uiCmd('f11')).to.eql('f11');
expect(iD.uiCmd('⌘plus')).to.eql('Ctrl+plus');
});