Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: CallRecord tersifies without undefined properties. #29

Merged
merged 1 commit into from
Jan 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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' } }`)
})
})
})