import { render, shallowRender } from '../src'; import { h, Component } from 'preact'; import chai, { expect } from 'chai'; import { spy, match } from 'sinon'; import sinonChai from 'sinon-chai'; chai.use(sinonChai); describe('pretty', () => { let prettyRender = jsx => render(jsx, {}, { pretty:true }); it('should render no whitespace by default', () => { let rendered = render(
foo bar

hello

); expect(rendered).to.equal(`
foobar

hello

`); }); it('should render whitespace when pretty=true', () => { let rendered = prettyRender(
foo bar

hello

); expect(rendered).to.equal(`
\n\tfoo\n\tbar\n\t

hello

\n
`); }); it('should not indent for short children', () => { let fourty = ''; for (let i=40; i--; ) fourty += 'x'; expect( prettyRender({fourty}), '<=40 characters' ).to.equal(`${fourty}`); expect( prettyRender({fourty+'a'}), '>40 characters' ).to.equal(`\n\t${fourty+'a'}\n`); }); it('should handle self-closing tags', () => { expect(prettyRender(
hi hi
)).to.equal(`
\n\thi\n\t\n\t\n\thi\n
`); }); it('should support empty tags', () => { expect(prettyRender(
)).to.equal(`
\n\t\n
`); }); });