Test cleanup and fixes [i-l]

This commit is contained in:
Angelos Chalaris
2018-06-18 17:31:56 +03:00
parent f67e121ed8
commit 82f0d6bc52
59 changed files with 358 additions and 452 deletions

View File

@ -1,25 +1,54 @@
const expect = require('expect');
const is = require('./is.js');
test('is is a Function', () => {
test('is is a Function', () => {
expect(is).toBeInstanceOf(Function);
});
t.true(is(Array, [1]), `Works for arrays with data`);
t.true(is(Array, []), `Works for empty arrays`);
t.false(is(Array, {}), `Works for arrays, not objects`);
t.true(is(Object, {}), `Works for objects`);
t.true(is(Map, new Map()), `Works for maps`);
t.true(is(RegExp, /./g), `Works for regular expressions`);
t.true(is(Set, new Set()), `Works for sets`);
t.true(is(WeakMap, new WeakMap()), `Works for weak maps`);
t.true(is(WeakSet, new WeakSet()), `Works for weak sets`);
t.true(is(String, ''), `Works for strings - returns true for primitive`);
t.true(is(String, new String('')), `Works for strings - returns true when using constructor`);
t.true(is(Number, 1), `Works for numbers - returns true for primitive`);
t.true(is(Number, new Number('10')), `Works for numbers - returns true when using constructor`);
t.true(is(Boolean, false), `Works for booleans - returns true for primitive`);
t.true(is(Boolean, new Boolean(false)), `Works for booleans - returns true when using constructor`);
t.true(is(Function, () => null), `Works for functions`);
test('Works for arrays with data', () => {
expect(is(Array, [1])).toBeTruthy();
});
test('Works for empty arrays', () => {
expect(is(Array, [])).toBeTruthy()
});
test('Works for arrays, not objects', () => {
expect(is(Array, {})).toBeFalsy();
});
test('Works for objects', () => {
expect(is(Object, {})).toBeTruthy();
});
test('Works for maps', () => {
expect(is(Map, new Map())).toBeTruthy();
});
test('Works for regular expressions', () => {
expect(is(RegExp, /./g)).toBeTruthy();
});
test('Works for sets', () => {
expect(is(Set, new Set())).toBeTruthy();
});
test('Works for weak maps', () => {
expect(is(WeakMap, new WeakMap())).toBeTruthy();
});
test('Works for weak sets', () => {
expect(is(WeakSet, new WeakSet())).toBeTruthy();
});
test('Works for strings - returns true for primitive', () => {
expect(is(String, '')).toBeTruthy();
});
test('Works for strings - returns true when using constructor', () => {
expect(is(String, new String(''))).toBeTruthy();
});
test('Works for numbers - returns true for primitive', () => {
expect(is(Number, 1)).toBeTruthy();
});
test('Works for numbers - returns true when using constructor', () => {
expect(is(Number, new Number('10'))).toBeTruthy()
});
test('Works for booleans - returns true for primitive', () => {
expect(is(Boolean, false)).toBeTruthy()
});
test('Works for booleans - returns true when using constructor', () => {
expect(is(Boolean, new Boolean(false))).toBeTruthy();
});
test('Works for functions', () => {
expect(is(Function, () => null)).toBeTruthy();
});