We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a5f91d5 commit 2fd1b68Copy full SHA for 2fd1b68
test/pluggability.test.js
@@ -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