From 41607f58561eb45c923c2854b12e8b600eca67a7 Mon Sep 17 00:00:00 2001 From: unional Date: Tue, 9 Jan 2018 19:44:39 -0800 Subject: [PATCH] test: add tersify test for asyncError chore: enable codecov --- .travis.yml | 1 + package-lock.json | 6 +++--- package.json | 3 ++- src/spy.spec.ts | 15 +++++++++++++++ 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2f2c6cd..a65e5e0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,3 +25,4 @@ after_script: greenkeeper-lockfile-upload after_success: - npm run travis-deploy-once "npm run semantic-release" - npm install --no-save coveralls && npm run coveralls + - npm install --no-save codecov && npm run codecov diff --git a/package-lock.json b/package-lock.json index 8745d6e..9309e45 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8558,9 +8558,9 @@ } }, "tersify": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/tersify/-/tersify-0.3.0.tgz", - "integrity": "sha512-gdA9qXE+OOa3IumLsRXPFlRYL2e8NY0goZVPThDddoe4S5QR6dYWIR/mqooLD6LS45sWTgrpGC5367EFo9MurA==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/tersify/-/tersify-1.0.1.tgz", + "integrity": "sha512-9GnuwmWXuZM0BY7gS1cz1w8xdKcSUlHQjidTujHmTF2s3x6aV3QBKRSdlk/3T9HB42c5/PfIlqQej3M9ofYqtA==", "requires": { "stringify-object": "3.2.1" } diff --git a/package.json b/package.json index 4609bcc..86a8814 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "build-es5": "tsc -p tsconfig.es5.json", "build-es2015": "tsc -p tsconfig.es2015.json", "clean": "rimraf dist dist-es5 && rimraf dist-es2015", + "codecov": "nyc report --reporter=json && codecov -f coverage/*.json", "coverage": "nyc npm test", "coveralls": "nyc report --reporter=text-lcov | coveralls", "dependency-check": "dependency-check . --unused --no-dev && dependency-check . --missing --no-dev", @@ -72,6 +73,6 @@ "typescript": "^2.6.2" }, "dependencies": { - "tersify": "^0.3.0" + "tersify": "^1.0.1" } } diff --git a/src/spy.spec.ts b/src/spy.spec.ts index 22b0ece..25d0f5d 100644 --- a/src/spy.spec.ts +++ b/src/spy.spec.ts @@ -1,6 +1,7 @@ import { test } from 'ava' import { spy } from './index' +import { tersify } from 'tersify'; function increment(x: number) { return ++x } @@ -99,3 +100,17 @@ test('catch() will receive error thrown by promise', async t => { }) }) }) + +test('tersify for sync call', async t => { + const { fn, calls } = spy(reject) + + + return fn(1).catch(actualError => { + console.log(tersify(actualError)) + return calls[0].getCallRecord() + .then(record => { + t.is(record.tersify(), `{ inputs: [1], output: {}, error: undefined, asyncError: { message: '1' } }`) + }) + }) +}) +