From b8c4b52d004e942bf2c65745895dd6966fa740c8 Mon Sep 17 00:00:00 2001 From: Michael Cousins Date: Wed, 8 May 2024 09:23:41 -0400 Subject: [PATCH] fixup: more typos and tweaks --- README.md | 2 +- src/debug.ts | 4 +++- test/vitest-when.test.ts | 11 ----------- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 02771f1..b29fca0 100644 --- a/README.md +++ b/README.md @@ -484,8 +484,8 @@ debug(coolFunc) // `coolFunc()` has: // // 2 stubbings with 0 calls -// - 0 calls: `coolFunc(4, 5, 6) => { throw [Error: oh no] }` // - 0 calls: `coolFunc(1, 2, 3) => 123` +// - 0 calls: `coolFunc(4, 5, 6) => { throw [Error: oh no] }` // // 1 unmatched call // - `coolFunc(1, 2, 4)` diff --git a/src/debug.ts b/src/debug.ts index 4581259..fa407c0 100644 --- a/src/debug.ts +++ b/src/debug.ts @@ -52,7 +52,9 @@ export const formatDebug = (debug: DebugResult): string => { 'stubbing', stubbingCount, )} with ${callCount} calls`, - ...stubbings.map((stubbing) => `- ${formatStubbing(name, stubbing)}`), + ...stubbings + .map((stubbing) => `- ${formatStubbing(name, stubbing)}`) + .reverse(), '', `${unmatchedCallsCount} unmatched ${plural('call', unmatchedCallsCount)}`, ...unmatchedCalls.map((args) => `- \`${formatCall(name, args)}\``), diff --git a/test/vitest-when.test.ts b/test/vitest-when.test.ts index 51022a1..cf1cd60 100644 --- a/test/vitest-when.test.ts +++ b/test/vitest-when.test.ts @@ -349,15 +349,4 @@ describe('vitest-when', () => { unmatchedCalls: [], }) }) - - it('logs debug description', () => { - const coolFunction = vi.fn().mockName('coolFunc') - - subject.when(coolFunction).calledWith(1, 2, 3).thenReturn(123) - subject.when(coolFunction).calledWith(4, 5, 6).thenThrow(new Error('oh no')) - - coolFunction(1, 2, 4) - - subject.debug(coolFunction) - }) })