main
 1// Copyright 2025 Google LLC
 2//
 3// Licensed under the Apache License, Version 2.0 (the "License");
 4// you may not use this file except in compliance with the License.
 5// You may obtain a copy of the License at
 6//
 7//     https://www.apache.org/licenses/LICENSE-2.0
 8//
 9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15import { test, describe } from 'node:test'
16import assert from 'node:assert'
17import { transformMarkdown } from '../src/md.ts'
18
19describe('md', () => {
20  test('transformMarkdown()', () => {
21    assert.equal(transformMarkdown('\n'), '// \n// ')
22    assert.equal(transformMarkdown('  \n    '), '  \n    ')
23    assert.equal(
24      transformMarkdown(`
25\t~~~js
26console.log('js')`),
27      `// \n\t~~~js\n// console.log('js')`
28    )
29    // prettier-ignore
30    assert.equal(transformMarkdown(`
31# Title
32    
33~~~js
34await $\`echo "js"\`
35~~~
36
37typescript code block
38~~~~~ts
39await $\`echo "ts"\`
40~~~~~
41
42~~~
43unknown code block
44~~~
45
46~~~sh
47echo foo
48~~~
49
50`), `// 
51// # Title
52//     
53
54await $\`echo "js"\`
55
56// 
57// typescript code block
58
59await $\`echo "ts"\`
60
61// 
62
63// unknown code block
64
65// 
66await $\`
67echo foo
68\`
69// 
70// `)
71  })
72})