-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
757 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
defaults and supports es6-module | ||
maintained node versions |
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,102 @@ | ||
import { render } from '@testing-library/vue' | ||
import { | ||
markdown, | ||
pMd, | ||
vPMd, | ||
} from '.' | ||
|
||
describe('markdown', () => { | ||
it('should able render markdown', () => { | ||
const result = markdown('**Hello** _world_') | ||
|
||
expect(result).toBe('<p><strong>Hello</strong> <em>world</em></p>\n') | ||
}) | ||
|
||
it('should sanitize result by default', () => { | ||
const result = markdown("123<a href='javascript:alert(1)'>I am a dolphin!</a>") | ||
|
||
expect(result).toBe('<p>123<a>I am a dolphin!</a></p>\n') | ||
}) | ||
|
||
it('should render inline when options.inline set to true', () => { | ||
const result = markdown('**Hello** _world_', { inline: true }) | ||
|
||
expect(result).toBe('<strong>Hello</strong> <em>world</em>') | ||
}) | ||
|
||
it('should not sanitize when options.unsecure set to true', () => { | ||
const result = markdown("123<a href='javascript:alert(1)'>I am a dolphin!</a>", { unsecure: true }) | ||
|
||
expect(result).toBe("<p>123<a href='javascript:alert(1)'>I am a dolphin!</a></p>\n") | ||
}) | ||
}) | ||
|
||
describe('v-p-md', () => { | ||
it('should able render markdown', () => { | ||
const screen = render({ | ||
directives: { pMd }, | ||
template : ` | ||
<div | ||
data-testid="sample" | ||
v-p-md="'**Hello** _world_'" | ||
/> | ||
`, | ||
}) | ||
|
||
const sample = screen.getByTestId('sample') | ||
|
||
expect(sample.innerHTML).toBe('<p><strong>Hello</strong> <em>world</em></p>\n') | ||
}) | ||
|
||
it('should sanitize result by default', () => { | ||
const screen = render({ | ||
directives: { pMd }, | ||
template : ` | ||
<div | ||
data-testid="sample" | ||
v-p-md="'123<a href=\\'javascript:alert(1)\\'>I am a dolphin!</a>'" | ||
/> | ||
`, | ||
}) | ||
|
||
const sample = screen.getByTestId('sample') | ||
|
||
expect(sample.innerHTML).toBe('<p>123<a>I am a dolphin!</a></p>\n') | ||
}) | ||
|
||
it('should render inline when add modifiers `inline`', () => { | ||
const screen = render({ | ||
directives: { pMd }, | ||
template : ` | ||
<div | ||
data-testid="sample" | ||
v-p-md.inline="'**Hello** _world_'" | ||
/> | ||
`, | ||
}) | ||
|
||
const sample = screen.getByTestId('sample') | ||
|
||
expect(sample.innerHTML).toBe('<strong>Hello</strong> <em>world</em>') | ||
}) | ||
|
||
it('should not sanitize when add modifiers `unsecure`', () => { | ||
const screen = render({ | ||
directives: { pMd }, | ||
template : ` | ||
<div | ||
data-testid="sample" | ||
v-p-md.unsecure="'123<a href=\\'javascript:alert(1)\\'>I am a dolphin!</a>'" | ||
/> | ||
`, | ||
}) | ||
|
||
const sample = screen.getByTestId('sample') | ||
|
||
expect(sample.innerHTML).toBe('<p>123<a href="javascript:alert(1)">I am a dolphin!</a></p>\n') | ||
}) | ||
|
||
it('should export alias vPMd', () => { | ||
expect(pMd).toBe(vPMd) | ||
}) | ||
}) |
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
Oops, something went wrong.