Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add svg test case
  • Loading branch information
wongchichong committed Mar 1, 2023
commit 854c251a5a2f5f34a2c16d745aba5f64bd7d3c11
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"name": "vhtml",
"amdName": "vhtml",
"version": "2.2.0",
"version": "2.2.1",
"description": "Hyperscript reviver that constructs a sanitized HTML string.",
"main": "dist/vhtml.js",
"minified:main": "dist/vhtml.min.js",
"jsnext:main": "src/vhtml.js",
"scripts": {
"preinstall": "npx only-allow pnpm",
"build": "vite build && tsc --declaration && pnpm size",
"tsc": "tsc",
"size": "echo \"gzip size: $(gzip-size $npm_package_minified_main | pretty-bytes)\"",
Expand Down
35 changes: 11 additions & 24 deletions test/vhtml.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,34 +195,21 @@ describe('vhtml', () => {
)
})

it('should support sortof components without args but with children', () => {
let items = ['one', 'two']

const Item = ({ children }) => (
<li>
<h4></h4>
{children}
</li>
)

it('should support svg', () => {
expect(
< !--comments -->
<div class="foo">
<h1>Hi!</h1>
<ul>
{items.map((item, index) => (
<Item>
This is item {item}!
</Item>
))}
</ul>
</div>
<svg viewBox="0 0 100 100">
<g transform="translate(50, 50)">
<circle class="clock-face" r={48} />
<line class="millisecond" y2={-44} />
<line class="hour" y2={-22} />
<line class="minute" y2={-32} />
<line class="second" y2={-38} />
</g>
</svg>
).to.equal(
`<div class="foo"><h1>Hi!</h1><ul><li><h4></h4>This is item one!</li><li><h4></h4>This is item two!</li></ul></div>`
`<svg viewBox="0 0 100 100"><g transform="translate(50, 50)"><circle class="clock-face" r="48"></circle><line class="millisecond" y2="-44"></line><line class="hour" y2="-22"></line><line class="minute" y2="-32"></line><line class="second" y2="-38"></line></g></svg>`
)
})


it('should support empty comment', () => {
expect(
h('!', null)
Expand Down