import { renderAttrs, renderClass, renderStyle, renderAttr } from '../src/helpers/renderAttrs' import { escapeHtml } from '@vue/shared' describe('ssr: renderAttrs', () => { test('ignore reserved props', () => { expect( renderAttrs({ key: 1, ref: () => {}, onClick: () => {} }) ).toBe('') }) test('normal attrs', () => { expect( renderAttrs({ id: 'foo', title: 'bar' }) ).toBe(` id="foo" title="bar"`) }) test('escape attrs', () => { expect( renderAttrs({ id: '"> { expect( renderAttrs({ checked: true, multiple: false }) ).toBe(` checked`) // boolean attr w/ false should be ignored }) test('ignore falsy values', () => { expect( renderAttrs({ foo: false, title: null, baz: undefined }) ).toBe(` foo="false"`) // non boolean should render `false` as is }) test('ingore non-renderable values', () => { expect( renderAttrs({ foo: {}, bar: [], baz: () => {} }) ).toBe(``) }) test('props to attrs', () => { expect( renderAttrs({ readOnly: true, // simple lower case conversion htmlFor: 'foobar' // special cases }) ).toBe(` readonly for="foobar"`) }) test('preserve name on custom element', () => { expect( renderAttrs( { fooBar: 'ok' }, 'my-el' ) ).toBe(` fooBar="ok"`) }) }) 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', '