import { describe, expect, it } from '@jest/globals';
import clipboard from '@powerfulyang/clipboardy';
import { html2md } from './html2md';
describe('html2md', () => {
it('should convert table to markdown', async () => {
const part = `
name
type
description
Copy code
console.log('hello world')
`;
const md = await html2md(html);
expect(md).toBe(
`\`\`\`javascript
console.log('hello world')
\`\`\``,
);
});
it('should convert pre to markdown(pre+~)', async () => {
const html = `
pip install -i https://mirrors.cloud.tencent.com/pypi/simple <some-package>`; const md = await html2md(html); expect(md).toBe(`\`\`\` pip install -i https://mirrors.cloud.tencent.com/pypi/simple
hello world
`; const md = await html2md(html); expect(md).toBe(`hello world`); }); it('should convert checkbox to markdown', async () => { const html = `x= (1.M)
e=E-1023
<input name="code" autocomplete="username">`;
const md = await html2md(html);
expect(md).toBe(`\`\`\`
\`\`\``);
});
it('来自张鑫旭的网站代码块02', async () => {
const html = `:-webkit-autofill { background-color: transparent; }
:autofill { background-color: transparent; }`;
const md = await html2md(html);
expect(md).toBe(`\`\`\`
:-webkit-autofill { background-color: transparent; }
:autofill { background-color: transparent; }
\`\`\``);
});
it('convert image', async () => {
const html = `
`;
const md = await html2md(html);
expect(md).toBe(
``,
);
});
it('convert url', async () => {
const html = `post title`;
const md = await html2md(html);
expect(md).toBe(`[post title](http://localhost/post/1)`);
});
});