1
0
mirror of https://github.com/lancedikson/bowser synced 2024-10-27 20:34:22 +00:00

Throw an error when minVersion map has not a string as a browser version

fixes #165
This commit is contained in:
Denis Demchenko 2016-10-31 11:07:15 +02:00
parent 533afc8fec
commit 8b92707e7b
2 changed files with 10 additions and 0 deletions

View File

@ -540,6 +540,10 @@
for (var browser in minVersions) {
if (minVersions.hasOwnProperty(browser)) {
if (_bowser[browser]) {
if (typeof minVersions[browser] !== 'string') {
throw new Error('Browser version in the minVersion map should be a string: ' + browser + ': ' + String(minVersions));
}
// browser version and min supported version.
return compareVersions([version, minVersions[browser]]) < 0;
}

View File

@ -127,6 +127,12 @@ describe('Unsupported browser check', function() {
assert.equal(supported, false);
});
it('should throw an error when minVersion map has a number, but not a string', function() {
assert.throws(() => {
browser.check({msie: 11}, this.ie10_6);
}, /Browser version in the minVersion map should be a string/);
});
it('should be passed by #check for IE10.6 when version was not specified', function() {
var supported = browser.check({}, this.ie10_6);
assert.equal(supported, true);