一些检查失败了
automerge / automerge (push) Has been cancelled
react-native-android-build-apk / AssembleRelease (push) Has been cancelled
Build macOS M1 / Main (push) Has been cancelled
Joplin Continuous Integration / Main (macos-15-intel) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-11-vs2026-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-2025) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04-arm) (push) Has been cancelled
Joplin UI tests / Main (ubuntu-22.04) (push) Has been cancelled
Joplin UI tests / Main (windows-2025) (push) Has been cancelled
Joplin UI tests / Mobile (push) Has been cancelled
Close stale issues / ProcessStaleIssues (push) Has been cancelled
32 行
1.0 KiB
TypeScript
32 行
1.0 KiB
TypeScript
import { runtime } from './convertHtmlToMarkdown';
|
|
import { CommandContext } from '../services/CommandService';
|
|
import { defaultState } from '../reducer';
|
|
import { Dispatch } from 'redux';
|
|
|
|
const command = runtime();
|
|
|
|
const makeContext = (): CommandContext => {
|
|
return {
|
|
state: defaultState,
|
|
dispatch: jest.fn(()=>{}) as Dispatch,
|
|
};
|
|
};
|
|
|
|
describe('convertHtmlToMarkdown', () => {
|
|
|
|
it.each([
|
|
['<b>test</b>', '**test**'],
|
|
['<a href="https://joplin.org">Joplin</a>', '[Joplin](https://joplin.org)'],
|
|
['<h1>Title</h1>\n<h2>Subtitle</h2>', '# Title\n\n## Subtitle'],
|
|
['<ul><li>One</li><li>Two</li></ul>', '- One\n- Two'],
|
|
['<p>First paragraph</p><p>This is the second paragraph</p>', 'First paragraph\n\nThis is the second paragraph'],
|
|
['<p>A paragraph with <strong>bold</strong> and <em>italic</em></p>', 'A paragraph with **bold** and *italic*'],
|
|
])('should turn HTML into Markdown', async (html, markdown) => {
|
|
const context = makeContext();
|
|
const result: string = await command.execute(context, html);
|
|
|
|
expect(result).toBe(markdown);
|
|
});
|
|
|
|
});
|