-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support rendering from pre-processed tokens (#53)
- Loading branch information
Abacus Lever
authored
Jul 21, 2022
1 parent
aa4bc51
commit 00301f3
Showing
4 changed files
with
66 additions
and
6 deletions.
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,31 @@ | ||
import '@testing-library/jest-dom/extend-expect' | ||
|
||
import { render, screen } from '@testing-library/svelte' | ||
|
||
import SvelteMarkdown from '../src/SvelteMarkdown.svelte' | ||
|
||
describe('testing initialization', () => { | ||
beforeAll(() => { | ||
console.warn = jest.fn() | ||
}) | ||
|
||
test('accepts pre-processed tokens as source', () => { | ||
render(SvelteMarkdown, { source: [{ | ||
type: 'paragraph', | ||
raw: 'this is an **example**', | ||
text: 'this is an **example**', | ||
tokens: [ | ||
{ type: 'text', raw: 'this is an ', text: 'this is an ' }, | ||
{ type: 'strong', | ||
raw: '**example**', | ||
text: 'example', | ||
tokens: [ { type: 'text', raw: 'example', text: 'example' } ], | ||
}, | ||
], | ||
}]}) | ||
|
||
const element = screen.getByText('example') | ||
expect(element).toBeInTheDocument() | ||
expect(element).toContainHTML('<strong>example</strong>') | ||
}) | ||
}) |
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