From 1d03414b806b9384ff4a26eac1ba7052c1b41228 Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Tue, 18 Oct 2016 21:56:24 -0400 Subject: [PATCH] Allow forced utilDetect(), useful for testing --- modules/util/detect.js | 4 ++-- test/spec/services/mapillary.js | 2 ++ test/spec/ui/cmd.js | 4 ++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/util/detect.js b/modules/util/detect.js index 4fa915a52..5f3bff7b0 100644 --- a/modules/util/detect.js +++ b/modules/util/detect.js @@ -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, diff --git a/test/spec/services/mapillary.js b/test/spec/services/mapillary.js index 587c62554..5fa84f660 100644 --- a/test/spec/services/mapillary.js +++ b/test/spec/services/mapillary.js @@ -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; }); }); diff --git a/test/spec/ui/cmd.js b/test/spec/ui/cmd.js index df622c75a..5369d319d 100644 --- a/test/spec/ui/cmd.js +++ b/test/spec/ui/cmd.js @@ -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'); });