test(ssr): test renderAttr

This commit is contained in:
Evan You 2020-02-04 18:42:13 -05:00
parent ebf920e6af
commit e2c5060fb4

View File

@ -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(