1
0
mirror of https://github.com/lancedikson/bowser synced 2024-09-28 22:30:44 +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) { for (var browser in minVersions) {
if (minVersions.hasOwnProperty(browser)) { if (minVersions.hasOwnProperty(browser)) {
if (_bowser[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. // browser version and min supported version.
return compareVersions([version, minVersions[browser]]) < 0; return compareVersions([version, minVersions[browser]]) < 0;
} }

View File

@ -127,6 +127,12 @@ describe('Unsupported browser check', function() {
assert.equal(supported, false); 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() { it('should be passed by #check for IE10.6 when version was not specified', function() {
var supported = browser.check({}, this.ie10_6); var supported = browser.check({}, this.ie10_6);
assert.equal(supported, true); assert.equal(supported, true);