Added some tests

This commit is contained in:
Angelos Chalaris
2018-01-28 16:41:20 +02:00
parent 06d7e04220
commit 10d2de5fab
5 changed files with 22 additions and 8 deletions

View File

@ -13,5 +13,5 @@ const Pall = collectInto(Promise.all.bind(Promise));
let p1 = Promise.resolve(1); let p1 = Promise.resolve(1);
let p2 = Promise.resolve(2); let p2 = Promise.resolve(2);
let p3 = new Promise(resolve => setTimeout(resolve, 2000, 3)); let p3 = new Promise(resolve => setTimeout(resolve, 2000, 3));
Pall(p1, p2, p3).then(console.log); Pall(p1, p2, p3).then(console.log); // [1, 2, 3] (after about 2 seconds)
``` ```

View File

@ -5,9 +5,14 @@ test('Testing collectInto', (t) => {
//For more information on all the methods supported by tape //For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape //Please go to https://github.com/substack/tape
t.true(typeof collectInto === 'function', 'collectInto is a Function'); t.true(typeof collectInto === 'function', 'collectInto is a Function');
const Pall = collectInto(Promise.all.bind(Promise));
let p1 = Promise.resolve(1);
let p2 = Promise.resolve(2);
let p3 = new Promise(resolve => setTimeout(resolve, 2000, 3));
Pall(p1, p2, p3).then(function(val){ t.deepEqual(val, [1,2,3], 'Works with multiple promises')}, function(reason){});
//t.deepEqual(collectInto(args..), 'Expected'); //t.deepEqual(collectInto(args..), 'Expected');
//t.equal(collectInto(args..), 'Expected'); //t.equal(collectInto(args..), 'Expected');
//t.false(collectInto(args..), 'Expected'); //t.false(collectInto(args..), 'Expected');
//t.throws(collectInto(args..), 'Expected'); //t.throws(collectInto(args..), 'Expected');
t.end(); t.end();
}); });

View File

@ -5,9 +5,11 @@ test('Testing countBy', (t) => {
//For more information on all the methods supported by tape //For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape //Please go to https://github.com/substack/tape
t.true(typeof countBy === 'function', 'countBy is a Function'); t.true(typeof countBy === 'function', 'countBy is a Function');
t.deepEqual(countBy([6.1, 4.2, 6.3], Math.floor), {4: 1, 6: 2}, 'Works for functions');
t.deepEqual(countBy(['one', 'two', 'three'], 'length'), {3: 2, 5: 1}, 'Works for property names');
//t.deepEqual(countBy(args..), 'Expected'); //t.deepEqual(countBy(args..), 'Expected');
//t.equal(countBy(args..), 'Expected'); //t.equal(countBy(args..), 'Expected');
//t.false(countBy(args..), 'Expected'); //t.false(countBy(args..), 'Expected');
//t.throws(countBy(args..), 'Expected'); //t.throws(countBy(args..), 'Expected');
t.end(); t.end();
}); });

View File

@ -5,9 +5,11 @@ test('Testing decapitalize', (t) => {
//For more information on all the methods supported by tape //For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape //Please go to https://github.com/substack/tape
t.true(typeof decapitalize === 'function', 'decapitalize is a Function'); t.true(typeof decapitalize === 'function', 'decapitalize is a Function');
t.equal(decapitalize('FooBar'), 'fooBar', 'Works with default parameter');
t.equal(decapitalize('FooBar', true), 'fOOBAR', 'Works with second parameter set to true');
//t.deepEqual(decapitalize(args..), 'Expected'); //t.deepEqual(decapitalize(args..), 'Expected');
//t.equal(decapitalize(args..), 'Expected'); //t.equal(decapitalize(args..), 'Expected');
//t.false(decapitalize(args..), 'Expected'); //t.false(decapitalize(args..), 'Expected');
//t.throws(decapitalize(args..), 'Expected'); //t.throws(decapitalize(args..), 'Expected');
t.end(); t.end();
}); });

View File

@ -1,4 +1,4 @@
Test log for: Sun Jan 28 2018 16:28:45 GMT+0200 (GTB Standard Time) Test log for: Sun Jan 28 2018 16:40:59 GMT+0200 (GTB Standard Time)
> 30-seconds-of-code@0.0.1 test G:\My Files\git Repositories\30-seconds-of-code > 30-seconds-of-code@0.0.1 test G:\My Files\git Repositories\30-seconds-of-code
> tape test/**/*.test.js | tap-spec > tape test/**/*.test.js | tap-spec
@ -186,6 +186,8 @@ Test log for: Sun Jan 28 2018 16:28:45 GMT+0200 (GTB Standard Time)
Testing countBy Testing countBy
√ countBy is a Function √ countBy is a Function
√ Works for functions
√ Works for property names
Testing countOccurrences Testing countOccurrences
@ -221,6 +223,8 @@ Test log for: Sun Jan 28 2018 16:28:45 GMT+0200 (GTB Standard Time)
Testing decapitalize Testing decapitalize
√ decapitalize is a Function √ decapitalize is a Function
√ Works with default parameter
√ Works with second parameter set to true
Testing deepClone Testing deepClone
@ -1601,10 +1605,11 @@ Test log for: Sun Jan 28 2018 16:28:45 GMT+0200 (GTB Standard Time)
Testing zipWith Testing zipWith
√ zipWith is a Function √ zipWith is a Function
√ Works with multiple promises
total: 716 total: 721
passing: 716 passing: 721
duration: 1.1s duration: 3.1s