import * as assert from 'assert'; import parse from './index.js'; describe( 'parse', () => { it( 'is a function', () => { assert.equal( typeof parse, 'function' ); }); it( 'parses a self-closing element', () => { const template = '
'; assert.deepEqual( parse( template ), { html: { start: 0, end: 6, type: 'Fragment', children: [ { start: 0, end: 6, type: 'Element', name: 'div', attributes: [], children: [] } ] }, css: null, js: null }); }); it( 'parses an element with text', () => { const template = `test`; assert.deepEqual( parse( template ), { html: { start: 0, end: 17, type: 'Fragment', children: [ { start: 0, end: 17, type: 'Element', name: 'span', attributes: [], children: [ { start: 6, end: 10, type: 'Text', data: 'test' } ] } ] }, css: null, js: null }); }); it( 'parses an element with a mustache tag', () => { const template = `{{animal}}
{{/each}}`; assert.deepEqual( parse( template ), { html: { start: 0, end: 53, type: 'Fragment', children: [ { start: 0, end: 53, type: 'EachBlock', expression: { start: 8, end: 15, type: 'Identifier', name: 'animals' }, context: 'animal', children: [ { start: 27, end: 44, type: 'Element', name: 'p', attributes: [], children: [ { start: 30, end: 40, type: 'MustacheTag', expression: { start: 32, end: 38, type: 'Identifier', name: 'animal' } } ] } ] } ] }, css: null, js: null }); }); });