|
3 | 3 | */ |
4 | 4 |
|
5 | 5 | import assert from 'node:assert/strict' |
6 | | -import {Buffer} from 'node:buffer' |
7 | 6 | import fs from 'node:fs/promises' |
8 | 7 | import test from 'node:test' |
9 | 8 | import {toHast} from 'mdast-util-to-hast' |
@@ -65,17 +64,33 @@ test('fromMarkdown', () => { |
65 | 64 | 'should parse a paragraph' |
66 | 65 | ) |
67 | 66 |
|
| 67 | + assert.deepEqual( |
| 68 | + fromMarkdown(new Uint8Array()), |
| 69 | + { |
| 70 | + type: 'root', |
| 71 | + children: [], |
| 72 | + position: { |
| 73 | + start: {line: 1, column: 1, offset: 0}, |
| 74 | + end: {line: 1, column: 1, offset: 0} |
| 75 | + } |
| 76 | + }, |
| 77 | + 'should support empty typed arrays' |
| 78 | + ) |
| 79 | + |
68 | 80 | assert.equal( |
69 | | - toString(fromMarkdown(Buffer.from([0x62,0x72,0xc3,0xa1,0x76,0x6f]))), |
70 | | - 'brávo', |
71 | | - 'should support buffers' |
| 81 | + toString(fromMarkdown(newTextEncoder().encode('<admin@example.com>'))), |
| 82 | + 'admin@example.com', |
| 83 | + 'should support types arrays' |
72 | 84 | ) |
73 | 85 |
|
74 | 86 | assert.equal( |
75 | 87 | toString( |
76 | | - fromMarkdown(Buffer.from([0x62, 0x72, 0xc3, 0xa1, 0x76, 0x6f]), 'ascii') |
| 88 | + fromMarkdown( |
| 89 | + new Uint8Array([0xff, 0xfe, 0x61, 0x00, 0x62, 0x00, 0x63, 0x00]), |
| 90 | + 'utf-16le' |
| 91 | + ) |
77 | 92 | ), |
78 | | - 'brC!vo', |
| 93 | + 'abc', |
79 | 94 | 'should support encoding' |
80 | 95 | ) |
81 | 96 |
|
|
0 commit comments