mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
This commit updates scripts within `packages/compiler` to relative imports as a prep work to the upcoming infra updates. PR Close #60625
61 lines
1.8 KiB
TypeScript
61 lines
1.8 KiB
TypeScript
/**
|
|
* @license
|
|
* Copyright Google LLC All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
* found in the LICENSE file at https://angular.dev/license
|
|
*/
|
|
|
|
import {HtmlParser} from '../../src/ml_parser/html_parser';
|
|
|
|
import {serializeNodes} from './util/util';
|
|
|
|
describe('Node serializer', () => {
|
|
let parser: HtmlParser;
|
|
|
|
beforeEach(() => {
|
|
parser = new HtmlParser();
|
|
});
|
|
|
|
it('should support element', () => {
|
|
const html = '<p></p>';
|
|
const ast = parser.parse(html, 'url');
|
|
expect(serializeNodes(ast.rootNodes)).toEqual([html]);
|
|
});
|
|
|
|
it('should support attributes', () => {
|
|
const html = '<p k="value"></p>';
|
|
const ast = parser.parse(html, 'url');
|
|
expect(serializeNodes(ast.rootNodes)).toEqual([html]);
|
|
});
|
|
|
|
it('should support text', () => {
|
|
const html = 'some text';
|
|
const ast = parser.parse(html, 'url');
|
|
expect(serializeNodes(ast.rootNodes)).toEqual([html]);
|
|
});
|
|
|
|
it('should support expansion', () => {
|
|
const html = '{number, plural, =0 {none} =1 {one} other {many}}';
|
|
const ast = parser.parse(html, 'url', {tokenizeExpansionForms: true});
|
|
expect(serializeNodes(ast.rootNodes)).toEqual([html]);
|
|
});
|
|
|
|
it('should support comment', () => {
|
|
const html = '<!--comment-->';
|
|
const ast = parser.parse(html, 'url', {tokenizeExpansionForms: true});
|
|
expect(serializeNodes(ast.rootNodes)).toEqual([html]);
|
|
});
|
|
|
|
it('should support nesting', () => {
|
|
const html = `<div i18n="meaning|desc">
|
|
<span>{{ interpolation }}</span>
|
|
<!--comment-->
|
|
<p expansion="true">
|
|
{number, plural, =0 {{sex, select, other {<b>?</b>}}}}
|
|
</p>
|
|
</div>`;
|
|
const ast = parser.parse(html, 'url', {tokenizeExpansionForms: true});
|
|
expect(serializeNodes(ast.rootNodes)).toEqual([html]);
|
|
});
|
|
});
|