Skip to content

Commit 881fc28

Browse files
committed
Test multiple switch cases
1 parent 15607e0 commit 881fc28

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

packages/angular-html-parser/test/index_spec.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,53 @@ describe("AST format", () => {
106106
],
107107
}),
108108
]);
109+
110+
{
111+
const input = `
112+
@switch (case) {
113+
@case (0)
114+
@case (1) {
115+
<div>case 0 or 1</div>
116+
}
117+
@case (2) {
118+
<div>case 2</div>
119+
}
120+
@default {
121+
<div>default</div>
122+
}
123+
}
124+
`;
125+
const ast = parse(input, { tokenizeAngularBlocks: true });
126+
expect(humanizeDom(ast)).toEqual([
127+
[html.Text, "\n", 0, ["\n"]],
128+
[html.Block, "switch", 0],
129+
[html.BlockParameter, "case"],
130+
[html.Text, "\n ", 1, ["\n "]],
131+
[html.Block, "case", 1],
132+
[html.BlockParameter, "0"],
133+
[html.Block, "case", 1],
134+
[html.BlockParameter, "1"],
135+
[html.Text, "\n ", 2, ["\n "]],
136+
[html.Element, "div", 2],
137+
[html.Text, "case 0 or 1", 3, ["case 0 or 1"]],
138+
[html.Text, "\n ", 2, ["\n "]],
139+
[html.Text, "\n ", 1, ["\n "]],
140+
[html.Block, "case", 1],
141+
[html.BlockParameter, "2"],
142+
[html.Text, "\n ", 2, ["\n "]],
143+
[html.Element, "div", 2],
144+
[html.Text, "case 2", 3, ["case 2"]],
145+
[html.Text, "\n ", 2, ["\n "]],
146+
[html.Text, "\n ", 1, ["\n "]],
147+
[html.Block, "default", 1],
148+
[html.Text, "\n ", 2, ["\n "]],
149+
[html.Element, "div", 2],
150+
[html.Text, "default", 3, ["default"]],
151+
[html.Text, "\n ", 2, ["\n "]],
152+
[html.Text, "\n", 1, ["\n"]],
153+
[html.Text, "\n ", 0, ["\n "]],
154+
]);
155+
}
109156
});
110157

111158
it("should support 'tokenizeAngularLetDeclaration'", () => {

0 commit comments

Comments
 (0)