Skip to content

Commit 78f52ce

Browse files
author
Dummy
committed
fixed issue regarding stringifying arguments.
1 parent 854a95b commit 78f52ce

File tree

7 files changed

+20
-16
lines changed

7 files changed

+20
-16
lines changed

dist/spec/index.test.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/spec/index.test.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/src/Arguments.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/src/Utilities.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/src/Utilities.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/index.test.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,14 @@ test('can call received twice', t => {
6868
substitute.c('blah', 'fuzz');
6969

7070
t.throws(() => substitute.received(1337).c('foo', 'bar'),
71-
`Expected 1337 calls to the method c with arguments [foo, bar], but received none of such calls.
71+
`Expected 1337 calls to the method c with arguments ['foo', 'bar'], but received none of such calls.
7272
All calls received to method c:
73-
-> 1 call with arguments [blah, fuzz]`);
73+
-> 1 call with arguments ['blah', 'fuzz']`);
7474

7575
t.throws(() => substitute.received(2117).c('foo', 'bar'),
76-
`Expected 2117 calls to the method c with arguments [foo, bar], but received none of such calls.
76+
`Expected 2117 calls to the method c with arguments ['foo', 'bar'], but received none of such calls.
7777
All calls received to method c:
78-
-> 1 call with arguments [blah, fuzz]`);
78+
-> 1 call with arguments ['blah', 'fuzz']`);
7979
});
8080

8181
test('class string field get received', t => {
@@ -164,10 +164,10 @@ test('class method received', t => {
164164
t.notThrows(() => substitute.received().c('hi', 'there'));
165165

166166
t.throws(() => substitute.received(7).c('hi', 'there'),
167-
`Expected 7 calls to the method c with arguments [hi, there], but received 4 of such calls.
167+
`Expected 7 calls to the method c with arguments ['hi', 'there'], but received 4 of such calls.
168168
All calls received to method c:
169-
-> 4 calls with arguments [hi, there]
170-
-> 1 call with arguments [hi, the1re]`);
169+
-> 4 calls with arguments ['hi', 'there']
170+
-> 1 call with arguments ['hi', 'the1re']`);
171171
});
172172

173173
test('received call matches after partial mocks using property instance mimicks', t => {
@@ -179,9 +179,9 @@ test('received call matches after partial mocks using property instance mimicks'
179179

180180
t.notThrows(() => substitute.received(1).c('lala', 'bar'));
181181
t.throws(() => substitute.received(2).c('lala', 'bar'),
182-
`Expected 2 calls to the method c with arguments [lala, bar], but received 1 of such call.
182+
`Expected 2 calls to the method c with arguments ['lala', 'bar'], but received 1 of such call.
183183
All calls received to method c:
184-
-> 1 call with arguments [lala, bar]`);
184+
-> 1 call with arguments ['lala', 'bar']`);
185185

186186
t.deepEqual(substitute.d, 1337);
187187
});

src/Utilities.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import { Argument, AllArguments } from "./Arguments";
2+
import util = require('util')
23

34
export type Call = {callCount: number, arguments?: any[]};
45

56
export function stringifyArguments(args: any[]) {
7+
args = args.map(x => util.inspect(x));
68
return args && args.length > 0 ? 'arguments [' + args.join(', ') + ']' : 'no arguments';
79
};
810

0 commit comments

Comments
 (0)