import { HtmlParser } from '@starptech/webparser' import fromWebParser from '../index' function getParserOpt() { return { ignoreFirstLf: false, decodeEntities: false, selfClosingCustomElements: true, selfClosingElements: true } } test('Attributes', () => { const parser = new HtmlParser(getParserOpt()) const result = parser.parse( `

`, 'TestComp' ) expect(result.errors.length).toBe(0) const node = fromWebParser(result.rootNodes, {}) expect(node).toMatchSnapshot() }) test('Element void', () => { const parser = new HtmlParser(getParserOpt()) const result = parser.parse( `

`, 'TestComp' ) expect(result.errors.length).toBe(0) const node = fromWebParser(result.rootNodes, {}) expect(node).toMatchSnapshot() }) test('Simple', () => { const parser = new HtmlParser(getParserOpt()) const result = parser.parse(`

foo

`, 'TestComp') expect(result.errors.length).toBe(0) const node = fromWebParser(result.rootNodes, {}) expect(node).toMatchSnapshot() }) test('SVG', () => { const parser = new HtmlParser(getParserOpt()) const result = parser.parse( `
`, 'TestComp' ) expect(result.errors.length).toBe(0) const node = fromWebParser(result.rootNodes, {}) expect(node).toMatchSnapshot() }) test('SVG - should preserve explicit svg namespace', () => { const parser = new HtmlParser(getParserOpt()) const result = parser.parse( `
`, 'TestComp' ) expect(result.errors.length).toBe(0) const node = fromWebParser(result.rootNodes, {}) expect(node).toMatchSnapshot() }) test('Template', () => { const parser = new HtmlParser(getParserOpt()) const result = parser.parse( ` `, 'TestComp' ) expect(result.errors.length).toBe(0) const node = fromWebParser(result.rootNodes, {}) expect(node).toMatchSnapshot() }) test('Comment', () => { const parser = new HtmlParser(getParserOpt()) const result = parser.parse(``, 'TestComp') expect(result.errors.length).toBe(0) const node = fromWebParser(result.rootNodes, {}) expect(node).toMatchSnapshot() }) test('Attributes with colon or @ as prefix', () => { const parser = new HtmlParser(getParserOpt()) const result = parser.parse(`
`, 'TestComp') expect(result.errors.length).toBe(0) const node = fromWebParser(result.rootNodes, {}) expect(node).toMatchSnapshot() }) test('Attributes with colon, binding syntax and namespace', () => { const parser = new HtmlParser(getParserOpt()) const result = parser.parse( `
`, 'TestComp' ) expect(result.errors.length).toBe(0) const node = fromWebParser(result.rootNodes, {}) expect(node).toMatchSnapshot() }) test('Case sensitive attributes', () => { const parser = new HtmlParser(getParserOpt()) const result = parser.parse(`
`, 'TestComp') expect(result.errors.length).toBe(0) const node = fromWebParser(result.rootNodes, {}) expect(node).toMatchSnapshot() }) test('Doctype', () => { const parser = new HtmlParser(getParserOpt()) const result = parser.parse(``, 'TestComp') expect(result.errors.length).toBe(0) const node = fromWebParser(result.rootNodes, {}) expect(node).toMatchSnapshot() }) test('Doctype nameless', () => { const parser = new HtmlParser(getParserOpt()) const result = parser.parse(``, 'TestComp') expect(result.errors.length).toBe(0) const node = fromWebParser(result.rootNodes, {}) expect(node).toMatchSnapshot() }) test('Doctype with html skeleton', () => { const parser = new HtmlParser(getParserOpt()) const result = parser.parse(`foo`, 'TestComp') expect(result.errors.length).toBe(0) const node = fromWebParser(result.rootNodes, {}) expect(node).toMatchSnapshot() }) test('Attributes with namespace', () => { const parser = new HtmlParser(getParserOpt()) const result = parser.parse(``, 'TestComp') expect(result.errors.length).toBe(0) const node = fromWebParser(result.rootNodes, {}) expect(node).toMatchSnapshot() }) test('Gaps detection - should set gapAfter data on elements followed by empty lines', () => { const parser = new HtmlParser(getParserOpt()) const result = parser.parse( `

Hello There

`, 'TestComp' ) expect(result.errors.length).toBe(0) const node = fromWebParser(result.rootNodes, {}) expect(node).toMatchSnapshot() })