|
8 | 8 |
|
9 | 9 | import * as html from '../../src/ml_parser/ast'; |
10 | 10 | import {HtmlParser} from '../../src/ml_parser/html_parser'; |
11 | | -import {ParseTreeResult, TreeError} from '../../src/ml_parser/parser'; |
12 | 11 | import {TokenizeOptions} from '../../src/ml_parser/lexer'; |
| 12 | +import {ParseTreeResult, TreeError} from '../../src/ml_parser/parser'; |
13 | 13 | import {ParseError} from '../../src/parse_util'; |
14 | 14 |
|
15 | 15 | import { |
@@ -1093,6 +1093,30 @@ describe('HtmlParser', () => { |
1093 | 1093 | ]); |
1094 | 1094 | }); |
1095 | 1095 |
|
| 1096 | + it('should parse empty cases in a switch block', () => { |
| 1097 | + expect( |
| 1098 | + humanizeDom( |
| 1099 | + parser.parse( |
| 1100 | + `@switch (expr) {@case ('foo') {} @case ('bar') {bar} @case('baz') { baz }}`, |
| 1101 | + `TestComp`, |
| 1102 | + ), |
| 1103 | + ), |
| 1104 | + ).toEqual([ |
| 1105 | + [html.Block, 'switch', 0], |
| 1106 | + [html.BlockParameter, 'expr'], |
| 1107 | + [html.Block, 'case', 1], |
| 1108 | + [html.BlockParameter, `'foo'`], |
| 1109 | + [html.Text, ' ', 1, [' ']], |
| 1110 | + [html.Block, 'case', 1], |
| 1111 | + [html.BlockParameter, `'bar'`], |
| 1112 | + [html.Text, 'bar', 2, ['bar']], |
| 1113 | + [html.Text, ' ', 1, [' ']], |
| 1114 | + [html.Block, 'case', 1], |
| 1115 | + [html.BlockParameter, `'baz'`], |
| 1116 | + [html.Text, ' baz ', 2, [' baz ']], |
| 1117 | + ]); |
| 1118 | + }); |
| 1119 | + |
1096 | 1120 | it('should close void elements used right before a block', () => { |
1097 | 1121 | expect(humanizeDom(parser.parse('<img>@defer {hello}', 'TestComp'))).toEqual([ |
1098 | 1122 | [html.Element, 'img', 0], |
|
0 commit comments