Tests for type checking
This commit is contained in:
@ -5,9 +5,12 @@ test('Testing isArrayLike', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof isArrayLike === 'function', 'isArrayLike is a Function');
|
||||
t.equal(isArrayLike('abc'), true, 'Returns true for a string');
|
||||
t.equal(isArrayLike([1,2,3]), true, 'Returns true for an array');
|
||||
t.equal(isArrayLike(null), false, 'Returns false for null');
|
||||
//t.deepEqual(isArrayLike(args..), 'Expected');
|
||||
//t.equal(isArrayLike(args..), 'Expected');
|
||||
//t.false(isArrayLike(args..), 'Expected');
|
||||
//t.throws(isArrayLike(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
@ -5,9 +5,19 @@ test('Testing isEmpty', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof isEmpty === 'function', 'isEmpty is a Function');
|
||||
t.equal(isEmpty(new Map()), true, 'Returns true for empty Map');
|
||||
t.equal(isEmpty(new Set()), true, 'Returns true for empty Set');
|
||||
t.equal(isEmpty([]), true, 'Returns true for empty array');
|
||||
t.equal(isEmpty({}), true, 'Returns true for empty object');
|
||||
t.equal(isEmpty(''), true, 'Returns true for empty string');
|
||||
t.equal(isEmpty([1, 2]), false, 'Returns false for non-empty array');
|
||||
t.equal(isEmpty({ a: 1, b: 2 }), false, 'Returns false for non-empty object');
|
||||
t.equal(isEmpty('text'), false, 'Returns false for non-empty string');
|
||||
t.equal(isEmpty(123), true, 'Returns true - type is not considered a collection');
|
||||
t.equal(isEmpty(true), true, 'Returns true - type is not considered a collection');
|
||||
//t.deepEqual(isEmpty(args..), 'Expected');
|
||||
//t.equal(isEmpty(args..), 'Expected');
|
||||
//t.false(isEmpty(args..), 'Expected');
|
||||
//t.throws(isEmpty(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
@ -5,9 +5,12 @@ test('Testing isNil', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof isNil === 'function', 'isNil is a Function');
|
||||
t.equal(isNil(null), true, 'Returns true for null');
|
||||
t.equal(isNil(undefined), true, 'Returns true for undefined');
|
||||
t.equal(isNil(''), false, 'Returns false for an empty string');
|
||||
//t.deepEqual(isNil(args..), 'Expected');
|
||||
//t.equal(isNil(args..), 'Expected');
|
||||
//t.false(isNil(args..), 'Expected');
|
||||
//t.throws(isNil(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
@ -5,9 +5,13 @@ test('Testing isObjectLike', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof isObjectLike === 'function', 'isObjectLike is a Function');
|
||||
t.equal(isObjectLike({}), true, 'Returns true for an object');
|
||||
t.equal(isObjectLike([1, 2, 3]), true, 'Returns true for an array');
|
||||
t.equal(isObjectLike(x => x), false, 'Returns false for a function');
|
||||
t.equal(isObjectLike(null), false, 'Returns false for null');
|
||||
//t.deepEqual(isObjectLike(args..), 'Expected');
|
||||
//t.equal(isObjectLike(args..), 'Expected');
|
||||
//t.false(isObjectLike(args..), 'Expected');
|
||||
//t.throws(isObjectLike(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
@ -5,9 +5,11 @@ test('Testing isPlainObject', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof isPlainObject === 'function', 'isPlainObject is a Function');
|
||||
t.equal(isPlainObject({ a: 1 }), true, 'Returns true for a plain object');
|
||||
t.equal(isPlainObject(new Map()), false, 'Returns false for a Map (example of non-plain object)');
|
||||
//t.deepEqual(isPlainObject(args..), 'Expected');
|
||||
//t.equal(isPlainObject(args..), 'Expected');
|
||||
//t.false(isPlainObject(args..), 'Expected');
|
||||
//t.throws(isPlainObject(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
@ -5,9 +5,16 @@ test('Testing isPromiseLike', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof isPromiseLike === 'function', 'isPromiseLike is a Function');
|
||||
t.equal(isPromiseLike({
|
||||
then: function() {
|
||||
return '';
|
||||
}
|
||||
}), true, 'Returns true for a promise-like object');
|
||||
t.equal(isPromiseLike(null), false, 'Returns false for null');
|
||||
t.equal(isPromiseLike({}), false, 'Returns false for an empty object');
|
||||
//t.deepEqual(isPromiseLike(args..), 'Expected');
|
||||
//t.equal(isPromiseLike(args..), 'Expected');
|
||||
//t.false(isPromiseLike(args..), 'Expected');
|
||||
//t.throws(isPromiseLike(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
@ -5,9 +5,10 @@ test('Testing isUndefined', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof isUndefined === 'function', 'isUndefined is a Function');
|
||||
t.true(isUndefined(undefined), 'Returns true for undefined');
|
||||
//t.deepEqual(isUndefined(args..), 'Expected');
|
||||
//t.equal(isUndefined(args..), 'Expected');
|
||||
//t.false(isUndefined(args..), 'Expected');
|
||||
//t.throws(isUndefined(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
32
test/testlog
32
test/testlog
@ -1,4 +1,4 @@
|
||||
Test log for: Sat Feb 03 2018 13:01:36 GMT+0200 (GTB Standard Time)
|
||||
Test log for: Sat Feb 03 2018 13:12:08 GMT+0200 (GTB Standard Time)
|
||||
|
||||
> 30-seconds-of-code@0.0.1 test G:\My Files\git Repositories\30-seconds-of-code
|
||||
> tape test/**/*.test.js | tap-spec
|
||||
@ -670,6 +670,9 @@ Test log for: Sat Feb 03 2018 13:01:36 GMT+0200 (GTB Standard Time)
|
||||
Testing isArrayLike
|
||||
|
||||
√ isArrayLike is a Function
|
||||
√ Returns true for a string
|
||||
√ Returns true for an array
|
||||
√ Returns false for null
|
||||
|
||||
Testing isBoolean
|
||||
|
||||
@ -685,6 +688,16 @@ Test log for: Sat Feb 03 2018 13:01:36 GMT+0200 (GTB Standard Time)
|
||||
Testing isEmpty
|
||||
|
||||
√ isEmpty is a Function
|
||||
√ Returns true for empty Map
|
||||
√ Returns true for empty Set
|
||||
√ Returns true for empty array
|
||||
√ Returns true for empty object
|
||||
√ Returns true for empty string
|
||||
√ Returns false for non-empty array
|
||||
√ Returns false for non-empty object
|
||||
√ Returns false for non-empty string
|
||||
√ Returns true - type is not considered a collection
|
||||
√ Returns true - type is not considered a collection
|
||||
|
||||
Testing isEven
|
||||
|
||||
@ -712,6 +725,9 @@ Test log for: Sat Feb 03 2018 13:01:36 GMT+0200 (GTB Standard Time)
|
||||
Testing isNil
|
||||
|
||||
√ isNil is a Function
|
||||
√ Returns true for null
|
||||
√ Returns true for undefined
|
||||
√ Returns false for an empty string
|
||||
|
||||
Testing isNull
|
||||
|
||||
@ -736,10 +752,16 @@ Test log for: Sat Feb 03 2018 13:01:36 GMT+0200 (GTB Standard Time)
|
||||
Testing isObjectLike
|
||||
|
||||
√ isObjectLike is a Function
|
||||
√ Returns true for an object
|
||||
√ Returns true for an array
|
||||
√ Returns false for a function
|
||||
√ Returns false for null
|
||||
|
||||
Testing isPlainObject
|
||||
|
||||
√ isPlainObject is a Function
|
||||
√ Returns true for a plain object
|
||||
√ Returns false for a Map (example of non-plain object)
|
||||
|
||||
Testing isPrime
|
||||
|
||||
@ -764,6 +786,9 @@ Test log for: Sat Feb 03 2018 13:01:36 GMT+0200 (GTB Standard Time)
|
||||
Testing isPromiseLike
|
||||
|
||||
√ isPromiseLike is a Function
|
||||
√ Returns true for a promise-like object
|
||||
√ Returns false for null
|
||||
√ Returns false for an empty object
|
||||
|
||||
Testing isRegExp
|
||||
|
||||
@ -805,6 +830,7 @@ Test log for: Sat Feb 03 2018 13:01:36 GMT+0200 (GTB Standard Time)
|
||||
Testing isUndefined
|
||||
|
||||
√ isUndefined is a Function
|
||||
√ Returns true for undefined
|
||||
|
||||
Testing isUpperCase
|
||||
|
||||
@ -1662,8 +1688,8 @@ Test log for: Sat Feb 03 2018 13:01:36 GMT+0200 (GTB Standard Time)
|
||||
√ Works with multiple promises
|
||||
|
||||
|
||||
total: 766
|
||||
passing: 766
|
||||
total: 792
|
||||
passing: 792
|
||||
duration: 2.4s
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user