test(ssr): test renderAttr
This commit is contained in:
parent
ebf920e6af
commit
e2c5060fb4
@ -1,10 +1,12 @@
|
||||
import {
|
||||
renderAttrs,
|
||||
renderClass,
|
||||
renderStyle
|
||||
renderStyle,
|
||||
renderAttr
|
||||
} from '../src/helpers/renderAttrs'
|
||||
import { escapeHtml } from '@vue/shared'
|
||||
|
||||
describe('ssr: renderProps', () => {
|
||||
describe('ssr: renderAttrs', () => {
|
||||
test('ignore reserved props', () => {
|
||||
expect(
|
||||
renderAttrs({
|
||||
@ -72,6 +74,23 @@ describe('ssr: renderProps', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('ssr: renderAttr', () => {
|
||||
test('basic', () => {
|
||||
expect(renderAttr('foo', 'bar')).toBe(` foo="bar"`)
|
||||
})
|
||||
|
||||
test('null and undefined', () => {
|
||||
expect(renderAttr('foo', null)).toBe(``)
|
||||
expect(renderAttr('foo', undefined)).toBe(``)
|
||||
})
|
||||
|
||||
test('escape', () => {
|
||||
expect(renderAttr('foo', '<script>')).toBe(
|
||||
` foo="${escapeHtml(`<script>`)}"`
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('ssr: renderClass', () => {
|
||||
test('via renderProps', () => {
|
||||
expect(
|
||||
|
Loading…
Reference in New Issue
Block a user