1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
import { describe, expect, it } from 'vitest';
import { formatResult } from '../../docs/.vitepress/components/api-docs/format';
describe('formatResult', () => {
it('should format undefined', () => {
const value = undefined;
const actual = formatResult(value);
expect(actual).toBeTypeOf('string');
expect(actual).toBe('undefined');
expect(actual).toMatchSnapshot();
});
it('should format bigint', () => {
const actual = formatResult(135464154865415n);
expect(actual).toBeTypeOf('string');
expect(actual).toMatchSnapshot();
});
it('should format object', () => {
const actual = formatResult({ a: 1, b: '2' });
expect(actual).toBeTypeOf('string');
expect(actual).toMatchSnapshot();
});
it('should format array', () => {
const actual = formatResult([1, '2']);
expect(actual).toBeTypeOf('string');
expect(actual).toMatchSnapshot();
});
it('should format string', () => {
const actual = formatResult('a simple string');
expect(actual).toBeTypeOf('string');
expect(actual).toMatchSnapshot();
});
it('should format string with special characters', () => {
const actual = formatResult('string with "special" characters');
expect(actual).toBeTypeOf('string');
expect(actual).toMatchSnapshot();
});
it('should format string with new lines', () => {
const actual = formatResult('string\nwith\nnew\nlines');
expect(actual).toBeTypeOf('string');
expect(actual).toMatchSnapshot();
});
it('should format number', () => {
const actual = formatResult(123);
expect(actual).toBeTypeOf('string');
expect(actual).toMatchSnapshot();
});
it('should format Date', () => {
const actual = formatResult(new Date(Date.UTC(2025, 0, 1)));
expect(actual).toBeTypeOf('string');
expect(actual).toMatchSnapshot();
});
});
|