Skip to content

Commit

Permalink
fix: CallRecord tersifies without undefined properties. (#29)
Browse files Browse the repository at this point in the history
Making it more terse to read.
  • Loading branch information
unional authored Jan 12, 2018
1 parent 9149cb5 commit 7f6c5f8
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 47 deletions.
71 changes: 34 additions & 37 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,18 @@
"devDependencies": {
"@types/node": "^8.5.8",
"ava": "^0.24.0",
"dependency-check": "^2.9.2",
"dependency-check": "^2.10.0",
"eslint": "^4.15.0",
"eslint-config-unional": "^0.2.3",
"nyc": "^11.4.1",
"rimraf": "^2.6.2",
"semantic-release": "^11.2.0",
"travis-deploy-once": "^4.3.0",
"tslint": "^5.8.0",
"tslint": "^5.9.1",
"tslint-config-unional": "^0.9.0",
"typescript": "^2.6.2"
},
"dependencies": {
"tersify": "^1.1.0"
"tersify": "^1.1.1"
}
}
13 changes: 6 additions & 7 deletions src/spy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ test('tersify for sync call', async t => {

t.is(fn(1), 2)
const record = await calls[0].getCallRecord()
t.is(record.tersify(), `{ inputs: [1], output: 2, error: undefined }`)
t.is(record.tersify(), `{ inputs: [1], output: 2 }`)
})

function throws() { throw new Error('thrown') }
Expand All @@ -40,7 +40,7 @@ test('tersify for throws call', async t => {
t.throws(fn)

const record = await calls[0].getCallRecord()
t.is(record.tersify(), `{ inputs: [], output: undefined, error: { message: 'thrown' } }`)
t.is(record.tersify(), `{ inputs: [], error: { message: 'thrown' } }`)
})

// this is not a valid test as the package is used for boundary testing.
Expand Down Expand Up @@ -69,7 +69,7 @@ test('tersify for callback', async t => {
fn(1, x => t.is(x, 1))

const record = await calls[0].getCallRecord()
t.is(record.tersify(), `{ inputs: [1, callback], output: undefined, error: undefined, asyncOutput: [1] }`)
t.is(record.tersify(), `{ inputs: [1, callback], asyncOutput: [1] }`)
})

function callbackLiteral(options) {
Expand Down Expand Up @@ -97,9 +97,8 @@ test('tersify for callback', async t => {
t.is(result, 2)
}
})

const record = await calls[0].getCallRecord()
t.is(record.tersify(), `{ inputs: [{ data: 1, success: callback }], output: undefined, error: undefined, asyncOutput: [2] }`)
t.is(record.tersify(), `{ inputs: [{ data: 1, success: callback }], asyncOutput: [2] }`)
})

const resolve = x => Promise.resolve(x)
Expand Down Expand Up @@ -138,7 +137,7 @@ test('tersify for resolve call', async t => {
fn(1)
return calls[0].getCallRecord()
.then(record => {
t.is(record.tersify(), `{ inputs: [1], output: {}, error: undefined, asyncOutput: 1 }`)
t.is(record.tersify(), `{ inputs: [1], output: {}, asyncOutput: 1 }`)
})
})

Expand All @@ -148,7 +147,7 @@ test('tersify for reject call', async t => {
return fn(1).catch(() => {
return calls[0].getCallRecord()
.then(record => {
t.is(record.tersify(), `{ inputs: [1], output: {}, error: undefined, asyncError: { message: '1' } }`)
t.is(record.tersify(), `{ inputs: [1], output: {}, asyncError: { message: '1' } }`)
})
})
})

0 comments on commit 7f6c5f8

Please sign in to comment.