Skip to content

Commit 2fd1b68

Browse files
committed
Plugins: Add incredibly basic test
1 parent a5f91d5 commit 2fd1b68

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

test/pluggability.test.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { expect, test } from 'vitest';
2+
import { print } from '../src';
3+
4+
/** @import { Handlers } from '../types' */
5+
test('custom printers work', () => {
6+
/** @type {Handlers} */
7+
const funkyStringPrinter = {
8+
Literal(node, state) {
9+
if (typeof node.value === 'string') {
10+
state.commands.push(`:) - `);
11+
12+
state.commands.push(node.value);
13+
14+
state.commands.push(` - (:`);
15+
}
16+
}
17+
};
18+
19+
const { code } = print(
20+
{
21+
type: 'Literal',
22+
value: 'testing 123'
23+
},
24+
{
25+
handlers: { ...funkyStringPrinter }
26+
}
27+
);
28+
29+
expect(code).toEqual(':) - testing 123 - (:');
30+
});

0 commit comments

Comments
 (0)