Test cleanup and fixes [w-z]
This commit is contained in:
@ -1,18 +1,16 @@
|
||||
const expect = require('expect');
|
||||
const when = require('./when.js');
|
||||
|
||||
|
||||
test('when is a Function', () => {
|
||||
expect(when).toBeInstanceOf(Function);
|
||||
});
|
||||
|
||||
const doubleEvenNumbers = when(
|
||||
(x) => x % 2 === 0,
|
||||
(x) => x * 2
|
||||
);
|
||||
|
||||
t.true(doubleEvenNumbers(2) === 4);
|
||||
t.true(doubleEvenNumbers(1) === 1);
|
||||
|
||||
|
||||
|
||||
test('Returns the proper result', () => {
|
||||
expect(doubleEvenNumbers(2)).toBe(4);
|
||||
});
|
||||
test('Returns the proper result', () => {
|
||||
expect(doubleEvenNumbers(1)).toBe(1);
|
||||
});
|
||||
|
||||
@ -1,27 +1,33 @@
|
||||
const expect = require('expect');
|
||||
const without = require('./without.js');
|
||||
|
||||
|
||||
test('without is a Function', () => {
|
||||
expect(without).toBeInstanceOf(Function);
|
||||
});
|
||||
test('without([2, 1, 2, 3], 1, 2) returns [3]', () => {
|
||||
expect(without([2, 1, 2, 3], 1, 2)).toEqual([3])
|
||||
expect(without([2, 1, 2, 3], 1, 2)).toEqual([3]);
|
||||
});
|
||||
test('without([]) returns []', () => {
|
||||
expect(without([])).toEqual([])
|
||||
expect(without([])).toEqual([]);
|
||||
});
|
||||
test('without([3, 1, true, '3', true], '3', true) returns [3, 1]', () => {
|
||||
expect(without([3, 1, true, '3', true], '3', true), [3).toEqual(1])
|
||||
expect(without([3, 1, true, '3', true], '3', true)).toEqual([3, 1]);
|
||||
});
|
||||
test('without('string'.split(''), 's', 't', 'g') returns ['r', 'i', 'n']', () => {
|
||||
expect(without('string'.split(''), 's', 't', 'g'), ['r', 'i').toEqual('n'])
|
||||
test('without('string'.split(''), 's', 't', 'g') returns [\'r\', \'i\', \'n\']', () => {
|
||||
expect(without('string'.split(''), 's', 't', 'g')).toEqual(['r', 'i', 'n']);
|
||||
});
|
||||
test('without() throws an error', () => {
|
||||
expect(without()).toThrow();
|
||||
});
|
||||
test('without(null) throws an error', () => {
|
||||
expect(without(null)).toThrow();
|
||||
});
|
||||
test('without(undefined) throws an error', () => {
|
||||
expect(without(undefined)).toThrow();
|
||||
});
|
||||
test('without(123) throws an error', () => {
|
||||
expect(without(123)).toThrow();
|
||||
});
|
||||
test('without({}) throws an error', () => {
|
||||
expect(without({})).toThrow();
|
||||
});
|
||||
t.throws(() => without(), 'without() throws an error');
|
||||
t.throws(() => without(null), 'without(null) throws an error');
|
||||
t.throws(() => without(undefined), 'without(undefined) throws an error');
|
||||
t.throws(() => without(123), 'without() throws an error');
|
||||
t.throws(() => without({}), 'without({}) throws an error');
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,25 +1,33 @@
|
||||
const expect = require('expect');
|
||||
const words = require('./words.js');
|
||||
|
||||
|
||||
test('words is a Function', () => {
|
||||
expect(words).toBeInstanceOf(Function);
|
||||
});
|
||||
test('words('I love javaScript!!') returns [I, love, javaScript]', () => {
|
||||
expect(words('I love javaScript!!'), ["I", "love").toEqual("javaScript"])
|
||||
expect(words('I love javaScript!!')).toEqual(["I", "love", "javaScript"]);
|
||||
});
|
||||
test('words('python, javaScript & coffee') returns [python, javaScript, coffee]', () => {
|
||||
expect(words('python, javaScript & coffee'), ["python", "javaScript").toEqual("coffee"])
|
||||
expect(words('python, javaScript & coffee')).toEqual(["python", "javaScript", "coffee"]);
|
||||
});
|
||||
test('words(I love javaScript!!) returns an array', () => {
|
||||
expect(Array.isArray(words('I love javaScript!!'))).toBeTruthy();
|
||||
});
|
||||
t.throws(() => words(), 'words() throws a error');
|
||||
t.throws(() => words(null), 'words(null) throws a error');
|
||||
t.throws(() => words(undefined), 'words(undefined) throws a error');
|
||||
t.throws(() => words({}), 'words({}) throws a error');
|
||||
t.throws(() => words([]), 'words([]) throws a error');
|
||||
t.throws(() => words(1234), 'words(1234) throws a error');
|
||||
|
||||
|
||||
|
||||
test('words() throws an error', () => {
|
||||
expect(words()).toThrow();
|
||||
});
|
||||
test('words(null) throws an error', () => {
|
||||
expect(words(null)).toThrow();
|
||||
});
|
||||
test('words(undefined) throws an error', () => {
|
||||
expect(words(undefined)).toThrow();
|
||||
});
|
||||
test('words({}) throws an error', () => {
|
||||
expect(words({})).toThrow();
|
||||
});
|
||||
test('words([]) throws an error', () => {
|
||||
expect(words([])).toThrow();
|
||||
});
|
||||
test('words(1234) throws an error', () => {
|
||||
expect(words(1234)).toThrow();
|
||||
});
|
||||
|
||||
@ -1,10 +1,9 @@
|
||||
const expect = require('expect');
|
||||
const xProd = require('./xProd.js');
|
||||
|
||||
|
||||
test('xProd is a Function', () => {
|
||||
expect(xProd).toBeInstanceOf(Function);
|
||||
});
|
||||
t.deepEqual(xProd([1, 2], ['a', 'b']), [[1, 'a'], [1, 'b'], [2, 'a'], [2, 'b']], `xProd([1, 2], ['a', 'b']) returns [[1, 'a'], [1, 'b'], [2, 'a'], [2, 'b']]`);
|
||||
|
||||
|
||||
test('xProd([1, 2], [\'a\', \'b\']) returns [[1, \'a\'], [1, \'b\'], [2, \'a\'], [2, \'b\']]', () => {
|
||||
expect(xProd([1, 2], ['a', 'b'])).toEqual([[1, 'a'], [1, 'b'], [2, 'a'], [2, 'b']]);
|
||||
});
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
const expect = require('expect');
|
||||
const yesNo = require('./yesNo.js');
|
||||
|
||||
|
||||
test('yesNo is a Function', () => {
|
||||
expect(yesNo).toBeInstanceOf(Function);
|
||||
});
|
||||
@ -41,6 +40,3 @@ const yesNo = require('./yesNo.js');
|
||||
test('yesNo({ 2: Yes }, true) returns true', () => {
|
||||
expect(yesNo({ 2: 'Yes' }, true)).toBeTruthy();
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
@ -6,16 +6,16 @@ const zip = require('./zip.js');
|
||||
expect(zip).toBeInstanceOf(Function);
|
||||
});
|
||||
test('zip([a, b], [1, 2], [true, false]) returns [[a, 1, true], [b, 2, false]]', () => {
|
||||
expect(zip(['a', 'b'], [1, 2], [true, false]), [['a', 1, true], ['b', 2, false]]).toEqual()
|
||||
expect(zip(['a', 'b'], [1, 2], [true, false])).toEqual([['a', 1, true], ['b', 2, false]]);
|
||||
});
|
||||
test('zip([a], [1, 2], [true, false]) returns [[a, 1, true], [undefined, 2, false]]', () => {
|
||||
expect(zip(['a'], [1, 2], [true, false]), [['a', 1, true], [undefined, 2, false]]).toEqual()
|
||||
expect(zip(['a'], [1, 2], [true, false])).toEqual([['a', 1, true], [undefined, 2, false]]);
|
||||
});
|
||||
test('zip([]) returns []', () => {
|
||||
expect(zip(), []).toEqual()
|
||||
expect(zip()).toEqual([]);
|
||||
});
|
||||
test('zip(123) returns []', () => {
|
||||
expect(zip(123), []).toEqual()
|
||||
expect(zip(123)).toEqual([]);
|
||||
});
|
||||
test('zip([a, b], [1, 2], [true, false]) returns an Array', () => {
|
||||
expect(Array.isArray(zip(['a', 'b'], [1, 2], [true, false]))).toBeTruthy();
|
||||
@ -23,8 +23,9 @@ const zip = require('./zip.js');
|
||||
test('zip([a], [1, 2], [true, false]) returns an Array', () => {
|
||||
expect(Array.isArray(zip(['a'], [1, 2], [true, false]))).toBeTruthy();
|
||||
});
|
||||
t.throws(() => zip(null), 'zip(null) throws an error');
|
||||
t.throws(() => zip(undefined), 'zip(undefined) throws an error');
|
||||
|
||||
|
||||
|
||||
test('zip(null) throws an error', () => {
|
||||
expect(zip(null)).toThrow();
|
||||
});
|
||||
test('zip(undefined) throws an error', () => {
|
||||
expect(zip(undefined)).toThrow();
|
||||
});
|
||||
|
||||
@ -1,27 +1,33 @@
|
||||
const expect = require('expect');
|
||||
const zipObject = require('./zipObject.js');
|
||||
|
||||
|
||||
test('zipObject is a Function', () => {
|
||||
expect(zipObject).toBeInstanceOf(Function);
|
||||
});
|
||||
test('zipObject([a, b, c], [1, 2]) returns {a: 1, b: 2, c: undefined}', () => {
|
||||
expect(zipObject(['a', 'b', 'c'], [1, 2]), {a: 1, b: 2, c: undefined}).toEqual()
|
||||
expect(zipObject(['a', 'b', 'c'], [1, 2])).toEqual({a: 1, b: 2, c: undefined});
|
||||
});
|
||||
test('zipObject([a, b], [1, 2, 3]) returns {a: 1, b: 2}', () => {
|
||||
expect(zipObject(['a', 'b'], [1, 2, 3]), {a: 1, b: 2}).toEqual()
|
||||
expect(zipObject(['a', 'b'], [1, 2, 3])).toEqual({a: 1, b: 2});
|
||||
});
|
||||
test('zipObject([a, b, c], string) returns { a: s, b: t, c: r }', () => {
|
||||
expect(zipObject(['a', 'b', 'c'], 'string'), { a: 's', b: 't', c: 'r' }).toEqual()
|
||||
expect(zipObject(['a', 'b', 'c'], 'string')).toEqual({ a: 's', b: 't', c: 'r' });
|
||||
});
|
||||
test('zipObject([a], string) returns { a: s }', () => {
|
||||
expect(zipObject(['a'], 'string'), { a: 's' }).toEqual()
|
||||
expect(zipObject(['a'], 'string')).toEqual({ a: 's' });
|
||||
});
|
||||
test('zipObject() throws an error', () => {
|
||||
expect(zipObject()).toThrow();
|
||||
});
|
||||
test('zipObject(([\'string\'], null) throws an error', () => {
|
||||
expect(zipObject((['string'], null)).toThrow();
|
||||
});
|
||||
test('zipObject(null, [1]) throws an error', () => {
|
||||
expect(zipObject(null, [1])).toThrow();
|
||||
});
|
||||
test('zipObject(\'string\') throws an error', () => {
|
||||
expect(zipObject('string')).toThrow();
|
||||
});
|
||||
test('zipObject(\'test\', \'string\') throws an error', () => {
|
||||
expect(zipObject('test', 'string')).toThrow();
|
||||
});
|
||||
t.throws(() => zipObject(), 'zipObject() throws an error');
|
||||
t.throws(() => zipObject(['string'], null), 'zipObject([string], null) throws an error');
|
||||
t.throws(() => zipObject(null, [1]), 'zipObject(null, [1]) throws an error');
|
||||
t.throws(() => zipObject('string'), 'zipObject(string) throws an error');
|
||||
t.throws(() => zipObject('test', 'string'), 'zipObject(test, string) throws an error');
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
const expect = require('expect');
|
||||
const zipWith = require('./zipWith.js');
|
||||
|
||||
|
||||
test('zipWith is a Function', () => {
|
||||
expect(zipWith).toBeInstanceOf(Function);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user