mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-20 23:44:47 +02:00
Allow forced utilDetect(), useful for testing
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user