mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 09:47:48 +00:00
Add initial test files from lodash v4. (#4172)
* Install test dependencies. * Add initial test files. These files were created using a simplistic AST manipulator using `recast` to preserve formatting. There's bound to be a huge chunk of errors, but this serves as a good start. QUnit was replaced with Mocha, with ES2015 imports running via `esm`. As far as possible, QUnit-specific syntax has been replaced with Mocha's `describe` and `it`, while the native Node.js `assert` module is used for assertions. Files in the `test` directory ending in `.test.js` will be treated as test files. * Add initial passing files to test run.
This commit is contained in:
committed by
John-David Dalton
parent
7606ea3e25
commit
d5ef31929a
39
test/isType-checks.js
Normal file
39
test/isType-checks.js
Normal file
@@ -0,0 +1,39 @@
|
||||
import assert from 'assert';
|
||||
import lodashStable from 'lodash';
|
||||
import { objToString, objectTag, _, xml } from './utils.js';
|
||||
|
||||
describe('isType checks', function() {
|
||||
it('should return `false` for subclassed values', function() {
|
||||
var funcs = [
|
||||
'isArray', 'isBoolean', 'isDate', 'isFunction',
|
||||
'isNumber', 'isRegExp', 'isString'
|
||||
];
|
||||
|
||||
lodashStable.each(funcs, function(methodName) {
|
||||
function Foo() {}
|
||||
Foo.prototype = root[methodName.slice(2)].prototype;
|
||||
|
||||
var object = new Foo;
|
||||
if (objToString.call(object) == objectTag) {
|
||||
assert.strictEqual(_[methodName](object), false, '`_.' + methodName + '` returns `false`');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('should not error on host objects (test in IE)', function() {
|
||||
var funcs = [
|
||||
'isArguments', 'isArray', 'isArrayBuffer', 'isArrayLike', 'isBoolean',
|
||||
'isBuffer', 'isDate', 'isElement', 'isError', 'isFinite', 'isFunction',
|
||||
'isInteger', 'isMap', 'isNaN', 'isNil', 'isNull', 'isNumber', 'isObject',
|
||||
'isObjectLike', 'isRegExp', 'isSet', 'isSafeInteger', 'isString',
|
||||
'isUndefined', 'isWeakMap', 'isWeakSet'
|
||||
];
|
||||
|
||||
lodashStable.each(funcs, function(methodName) {
|
||||
if (xml) {
|
||||
_[methodName](xml);
|
||||
assert.ok(true, '`_.' + methodName + '` should not error');
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user