thunk-test
Advanced tools
Comparing version 0.0.1 to 0.1.0
{ | ||
"name": "thunk-test", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"description": "Modular testing for JavaScript", | ||
@@ -5,0 +5,0 @@ "author": "Richard Tong", |
@@ -14,2 +14,5 @@ # thunk-test | ||
thunkTestForAdd() | ||
// adds two values | ||
// ✓ (5, 5) -> 10 | ||
// ✓ (abcde, fg) -> callback(...) | ||
``` |
@@ -7,2 +7,10 @@ const ThunkTest = require('./thunk-test') | ||
const add = (a, b) => a + b | ||
ThunkTest('adds two values', add) | ||
.case(5, 5, 10) // assert.strictEqual(add(5, 5), 10) | ||
.case('abcde', 'fg', result => { // supply your own callback | ||
assert.strictEqual(result, 'abcdefg') | ||
})() | ||
ThunkTest( | ||
@@ -9,0 +17,0 @@ 'pipe: awesome username generator', |
@@ -60,2 +60,14 @@ const noop = function () {} | ||
/** | ||
* @name log | ||
* | ||
* @synopsis | ||
* ```coffeescript [specscript] | ||
* log(args ...any) -> () | ||
* ``` | ||
*/ | ||
const log = function (...args) { | ||
console.log(...args) | ||
} | ||
/** | ||
* @name AssertionError | ||
@@ -88,4 +100,4 @@ * | ||
if (expected !== actual) { | ||
console.log('expected', expected) | ||
console.log('actual', actual) | ||
log('expected', expected) | ||
log('actual', actual) | ||
throw AssertionError('not strict equal') | ||
@@ -107,10 +119,10 @@ } | ||
if (actual.name != expected.name) { | ||
console.log() | ||
console.log('-- expect:', expected.name) | ||
console.log('-- actual:', actual.name) | ||
log() | ||
log('-- expect:', expected.name) | ||
log('-- actual:', actual.name) | ||
throw AssertionError('error names are different') | ||
} else if (actual.message != expected.message) { | ||
console.log() | ||
console.log('-- expect:', expected.message) | ||
console.log('-- actual:', actual.message) | ||
log() | ||
log('-- expect:', expected.message) | ||
log('-- actual:', actual.message) | ||
throw AssertionError('error messages are different') | ||
@@ -173,6 +185,6 @@ } | ||
return execution.then(funcConcat( | ||
tapSync(thunkify1(console.log, ` ✓ ${argsInspect(args)} throws ...`)), | ||
tapSync(thunkify1(log, ` ✓ ${argsInspect(args)} throws ...`)), | ||
noop)) | ||
} | ||
console.log(` ✓ ${argsInspect(args)} throws ...`) | ||
log(` ✓ ${argsInspect(args)} throws ...`) | ||
return undefined | ||
@@ -203,3 +215,3 @@ } | ||
*/ | ||
const funcInspect = func => `${func.name || 'callback'}()` | ||
const funcInspect = func => `${func.name || 'callback'}(${func.length == 0 ? '' : '...'})` | ||
@@ -230,3 +242,3 @@ /** | ||
return objectAssign(function thunkTest() { | ||
console.log(name) | ||
log(name) | ||
const operationsLength = operations.length, | ||
@@ -250,3 +262,3 @@ promises = [] | ||
expected, | ||
tapSync(thunkify1(console.log, ` ✓ ${argsInspect(args)} -> ${funcInspect(expected)}`)), | ||
tapSync(thunkify1(log, ` ✓ ${argsInspect(args)} -> ${funcInspect(expected)}`)), | ||
].reduce(funcConcat)) | ||
@@ -257,3 +269,3 @@ } else { | ||
curry2(assertStrictEqual, expected, __), | ||
tapSync(thunkify1(console.log, ` ✓ ${argsInspect(args)} -> ${expected}`)), | ||
tapSync(thunkify1(log, ` ✓ ${argsInspect(args)} -> ${expected}`)), | ||
].reduce(funcConcat)) | ||
@@ -277,6 +289,6 @@ } | ||
return execution.then(funcConcat( | ||
tapSync(thunkify1(console.log, ` ✓ ${argsInspect(args)} throws ...`)), | ||
tapSync(thunkify1(log, ` ✓ ${argsInspect(args)} throws ...`)), | ||
noop)) | ||
} | ||
console.log(` ✓ ${argsInspect(args)} throws ...`) | ||
log(` ✓ ${argsInspect(args)} throws ...`) | ||
return undefined | ||
@@ -289,3 +301,3 @@ } | ||
thunkify2(assertThrows, thunkifyArgs(func, args), expected), | ||
tapSync(thunkify1(console.log, ` ✓ ${argsInspect(args)} throws ${expected}`)), | ||
tapSync(thunkify1(log, ` ✓ ${argsInspect(args)} throws ${expected}`)), | ||
)) | ||
@@ -292,0 +304,0 @@ } |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
9849
308
18
0