Skip to content

Commit

Permalink
Updated stringifyVal output to match node function output more
Browse files Browse the repository at this point in the history
  • Loading branch information
CoryDanielson committed Apr 19, 2017
1 parent e8b2e13 commit ad5a016
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ function stringifyVal(val) {
return JSON.stringify(val, (key, val) => {
if (typeof val === 'function') {
if (val.name) {
return val.name;
return `[Function: ${val.name}]`;
} else {
return `anonymous function: ${val.toString()}`;
return `[Function]: ${val.toString()}`;
}
}
return val;
Expand Down
4 changes: 2 additions & 2 deletions tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ test('sagaTestEngine throws under bad conditions', t => {
const badMapping2 = [['no', 'functions']]
t.throws(
() => sagaTestEngine(f2, badMapping2),
`Env Mapping is missing a value for ${JSON.stringify({ "func": "namedFunction" }, null, 2)}`
`Env Mapping is missing a value for ${JSON.stringify({ "func": "[Function: namedFunction]" }, null, 2)}`
)

// Bad mapping for saga that yields object with anonymous function
Expand All @@ -189,7 +189,7 @@ test('sagaTestEngine throws under bad conditions', t => {
const badMapping3 = [['also no', 'functions']]
t.throws(
() => sagaTestEngine(f3, badMapping3),
`Env Mapping is missing a value for ${JSON.stringify({ func: `anonymous function: ${anonymousFunction.toString()}` }, null, 2)}`
`Env Mapping is missing a value for ${JSON.stringify({ func: `[Function]: ${anonymousFunction.toString()}` }, null, 2)}`
)

// No errors thrown
Expand Down

0 comments on commit ad5a016

Please sign in to comment.