2020-02-02 22:08:20 -05:00
|
|
|
import { compile } from '../src'
|
2020-02-02 21:47:10 -05:00
|
|
|
|
|
|
|
function getElementString(src: string): string {
|
|
|
|
return compile(src).code.match(/_push\((.*)\)/)![1]
|
|
|
|
}
|
|
|
|
|
2020-02-02 22:08:20 -05:00
|
|
|
describe('ssr compile integration test', () => {
|
2020-02-02 21:47:10 -05:00
|
|
|
test('basic elements', () => {
|
|
|
|
expect(getElementString(`<div></div>`)).toMatchInlineSnapshot(
|
|
|
|
`"\`<div></div>\`"`
|
|
|
|
)
|
|
|
|
})
|
|
|
|
|
|
|
|
test('static attrs', () => {
|
|
|
|
expect(
|
|
|
|
getElementString(`<div id="foo" class="bar"></div>`)
|
|
|
|
).toMatchInlineSnapshot(`"\`<div id=\\"foo\\" class=\\"bar\\"></div>\`"`)
|
|
|
|
})
|
|
|
|
|
|
|
|
test('nested elements', () => {
|
|
|
|
expect(
|
|
|
|
getElementString(`<div><span></span><span></span></div>`)
|
|
|
|
).toMatchInlineSnapshot(`"\`<div><span></span><span></span></div>\`"`)
|
|
|
|
})
|
2020-02-02 22:08:20 -05:00
|
|
|
|
|
|
|
test('nested elements with static text', () => {
|
|
|
|
expect(
|
|
|
|
getElementString(`<div><span>hello</span>><span>bye</span></div>`)
|
|
|
|
).toMatchInlineSnapshot(
|
|
|
|
`"\`<div><span>hello</span>><span>bye</span></div>\`"`
|
|
|
|
)
|
|
|
|
})
|
2020-02-02 21:47:10 -05:00
|
|
|
})
|