Fix tests under IE

This commit is contained in:
kpdecker
2015-09-23 21:59:49 -05:00
parent fffb5a985f
commit 861d6f7b8d
4 changed files with 11 additions and 7 deletions
+3 -1
View File
@@ -1,3 +1,5 @@
import {indexOf} from './utils';
let logger = {
methodMap: ['debug', 'info', 'warn', 'error'],
level: 'info',
@@ -5,7 +7,7 @@ let logger = {
// Maps a given level value to the `methodMap` indexes above.
lookupLevel: function(level) {
if (typeof level === 'string') {
let levelMap = logger.methodMap.indexOf(level.toLowerCase());
let levelMap = indexOf(logger.methodMap, level.toLowerCase());
if (levelMap >= 0) {
level = levelMap;
} else {
+5 -5
View File
@@ -61,12 +61,12 @@ global.shouldThrow = function(callback, type, msg) {
try {
callback();
failed = true;
} catch (err) {
if (type && !(err instanceof type)) {
throw new AssertError('Type failure: ' + err);
} catch (caught) {
if (type && !(caught instanceof type)) {
throw new AssertError('Type failure: ' + caught);
}
if (msg && !(msg.test ? msg.test(err.message) : msg === err.message)) {
throw new AssertError('Throw mismatch: Expected ' + err.message + ' to match ' + msg + '\n\n' + err.stack, shouldThrow);
if (msg && !(msg.test ? msg.test(caught.message) : msg === caught.message)) {
throw new AssertError('Throw mismatch: Expected ' + caught.message + ' to match ' + msg + '\n\n' + caught.stack, shouldThrow);
}
}
if (failed) {
+1
View File
@@ -1,3 +1,4 @@
<!doctype html>
<html>
<head>
<title>Mocha</title>
+2 -1
View File
@@ -215,7 +215,8 @@ describe('Regressions', function() {
return 'found';
}
}
return 'not';
// And to make IE happy, check for the known string as length is not enumerated.
return (this == 'bat' ? 'found' : 'not');
}
};