-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Chore: Added tests for renderMarkup command
- Loading branch information
Showing
4 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import shim from '@joplin/lib/shim'; | ||
import Resource from '@joplin/lib/models/Resource'; | ||
import Note from '@joplin/lib/models/Note'; | ||
import { setupDatabaseAndSynchronizer, supportDir, switchClient } from '@joplin/lib/testing/test-utils'; | ||
import { runtime } from './renderMarkup'; | ||
import { MarkupLanguage } from '@joplin/renderer'; | ||
const testImagePath = `${supportDir}/photo.jpg`; | ||
|
||
const command = runtime(); | ||
|
||
describe('renderMarkup', () => { | ||
|
||
beforeEach(async () => { | ||
await setupDatabaseAndSynchronizer(1); | ||
await switchClient(1); | ||
}); | ||
|
||
test('should return the rendered note as HTML', async () => { | ||
{ | ||
const renderedNote = await command.execute(null, MarkupLanguage.Markdown, 'hello **strong**'); | ||
expect(renderedNote.html).toBe('<div id="rendered-md"><p>hello <strong>strong</strong></p>\n</div>'); | ||
expect(!!renderedNote.pluginAssets).toBe(true); | ||
expect(!!renderedNote.cssStrings).toBe(true); | ||
} | ||
|
||
{ | ||
const renderedNote = await await command.execute(null, MarkupLanguage.Markdown, '- [ ] Beer\n- [x] Milk\n- [ ] Eggs'); | ||
expect(renderedNote.html).toContain('checkbox-label-unchecked">Beer'); | ||
expect(renderedNote.html).toContain('checkbox-label-checked">Milk'); | ||
expect(renderedNote.html).toContain('checkbox-label-unchecked">Eggs'); | ||
expect(!!renderedNote.pluginAssets).toBe(true); | ||
expect(!!renderedNote.cssStrings).toBe(true); | ||
} | ||
|
||
{ | ||
const note = await Note.save({ }); | ||
await shim.attachFileToNote(note, testImagePath, null, { resizeLargeImages: 'never' }); | ||
const resource = (await Resource.all())[0]; | ||
const noteBody = (await Note.load(note.id)).body; | ||
const renderedNote = await await command.execute(null, MarkupLanguage.Markdown, noteBody); | ||
expect(renderedNote.html).toContain(`<div id="rendered-md"><p><img data-from-md data-resource-id="${resource.id}" src="joplin-content://note-viewer//Users/laurent/src/joplin/packages/lib/testing/../../app-cli/tests/test data/`); | ||
expect(renderedNote.html).toContain(`/resources-1/${resource.id}.jpg?t=`); | ||
expect(renderedNote.html).toContain('" title alt="photo.jpg" /></p>'); | ||
} | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This change seems to be causing
tsc
failures: