Skip to content

Commit fb61d69

Browse files
committed
Improve Jest snapshot based on PR feedback
1 parent 820573d commit fb61d69

File tree

2 files changed

+240
-228
lines changed

2 files changed

+240
-228
lines changed

libraries/rushell/src/test/Tokenizer.test.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,22 @@ function tokenize(input: string): Token[] {
1717

1818
function matchSnapshot(input: string): void {
1919
const tokenizer: Tokenizer = new Tokenizer(input);
20-
expect({
21-
input: escape(tokenizer.input.toString()),
22-
tokens: tokenizer.getTokens().map(x => [TokenKind[x.kind], escape(x.toString())])
23-
}).toMatchSnapshot();
20+
21+
const reportedTokens = tokenizer.getTokens().map(
22+
token => {
23+
return {
24+
kind: TokenKind[token.kind],
25+
value: escape(token.toString())
26+
}
27+
}
28+
);
29+
30+
expect(
31+
{
32+
input: escape(tokenizer.input.toString()),
33+
tokens: reportedTokens
34+
}
35+
).toMatchSnapshot();
2436
}
2537

2638
test('00: empty inputs', () => {

0 commit comments

Comments
 (0)