2424
2525 it 'lexes TypeScript code outside template blocks' do
2626 assert_has_token 'Keyword' , 'import Component from "@glimmer/component";'
27- assert_has_token 'Name.Class' , 'export default class MyComponent extends Component {'
27+ assert_has_token 'Name.Class' ,
28+ 'export default class MyComponent extends Component {'
2829 assert_has_token 'Name.Decorator' , '@tracked count: number = 0;'
2930 end
3031
3839 };
3940 }
4041 GTS
41-
42+
4243 assert_has_token 'Keyword.Reserved' , code # interface
4344 assert_has_token 'Name.Other' , code # ComponentSignature
4445 assert_has_token 'Keyword.Reserved' , code # string, number
5253 it 'lexes handlebars expressions in templates' do
5354 code = '<template><div>{{@name}}</div></template>'
5455 assert_has_token 'Keyword' , code # {{ and }}
55- assert_has_token 'Name.Attribute' , code # @name (tokenized as attribute by handlebars)
56+ assert_has_token 'Name.Attribute' , code
5657 assert_has_token 'Name.Tag' , code # template and div tags
5758 end
5859
6465 end
6566
6667 it 'lexes handlebars with modifiers' do
67- code = '<template><button {{on "click" this.handleClick}}>Click</button></template>'
68+ code = '<template>' \
69+ '<button {{on "click" this.handleClick}}>Click</button>' \
70+ '</template>'
6871 assert_has_token 'Keyword' , code # {{ and }}
6972 assert_has_token 'Name.Variable' , code # on
7073 assert_has_token 'Literal.String.Double' , code # "click"
7679 Args: { name: string };
7780 }
7881
79- export default class MyComponent extends Component<MyComponentSignature> {
82+ export default class MyComponent extends
83+ Component<MyComponentSignature> {
8084 @tracked count: number = 0;
8185
8286 get greeting(): string {
9094 </template>
9195 }
9296 GTS
93-
97+
9498 assert_has_token 'Keyword.Reserved' , code # interface
9599 assert_has_token 'Keyword' , code # export, default, class, extends, get
96100 assert_has_token 'Name.Class' , code # MyComponent, Component
116120 {{/if}}
117121 </template>;
118122 GTS
119-
123+
120124 assert_has_token 'Keyword' , code # import, type, const
121125 assert_has_token 'Keyword.Reserved' , code # interface
122126 assert_has_token 'Keyword.Reserved' , code # string, boolean
138142 </template>
139143 }
140144 GTS
141-
145+
142146 assert_has_token 'Keyword.Reserved' , code # interface
143147 assert_has_token 'Name.Class' , code # List, Component
144148 assert_has_token 'Punctuation' , code # <, >, [, ]
147151 end
148152
149153 it 'lexes nested handlebars expressions' do
150- code = '<template>{{#each @items as |item|}}{{item.name}}{{/each}}</template>'
154+ code = '<template>' \
155+ '{{#each @items as |item|}}{{item.name}}{{/each}}' \
156+ '</template>'
151157 assert_has_token 'Keyword' , code # {{#each, {{/each
152158 assert_has_token 'Name.Attribute' , code # @items, item.name
153159 assert_has_token 'Name.Tag' , code # template
154160 end
155161
156162 it 'lexes handlebars with yield and blocks' do
157- code = '<template><div>{{yield (hash name=@name age=@age)}}</div></template>'
163+ code = '<template>' \
164+ '<div>{{yield (hash name=@name age=@age)}}</div>' \
165+ '</template>'
158166 assert_has_token 'Keyword' , code # {{ and }}
159167 assert_has_token 'Name.Variable' , code # yield, hash
160168 assert_has_token 'Name.Attribute' , code # @name, @age
179187 </template>
180188 }
181189 GTS
182-
190+
183191 assert_has_token 'Keyword.Declaration' , code # type
184192 assert_has_token 'Name.Decorator' , code # @tracked
185193 assert_has_token 'Name.Other' , code # Status (type annotation)
@@ -195,7 +203,7 @@ class MyComponent extends Component {
195203 </template>
196204 }
197205 GTS
198-
206+
199207 # Test that we properly enter and exit template mode
200208 assert_has_token 'Keyword' , code # class, extends
201209 assert_has_token 'Name.Tag' , code # <template>, <div>
@@ -215,23 +223,31 @@ class MyComponent extends Component {
215223 end
216224
217225 it 'lexes splattributes syntax' do
218- code = '<template><div class="some-class" ...attributes>{{@someValue}}</div></template>'
226+ code = '<template>' \
227+ '<div class="some-class" ...attributes>{{@someValue}}</div>' \
228+ '</template>'
219229 assert_has_token 'Operator' , code # ... operator
220230 assert_has_token 'Name.Attribute' , code # attributes and class
221231 assert_has_token 'Name.Tag' , code # div tags
222232 assert_has_token 'Name.Attribute' , code # @someValue
223233 end
224234
225235 it 'lexes splattributes with other attributes' do
226- code = '<template><button type="button" ...attributes {{on "click" @onClick}}>Click</button></template>'
236+ code = '<template>' \
237+ '<button type="button" ...attributes {{on "click" @onClick}}>' \
238+ 'Click' \
239+ '</button>' \
240+ '</template>'
227241 assert_has_token 'Operator' , code # ... operator
228242 assert_has_token 'Name.Attribute' , code # type, attributes, on
229243 assert_has_token 'Literal.String' , code # "button", "click"
230244 assert_has_token 'Keyword' , code # {{ and }}
231245 end
232246
233247 it 'lexes splattributes in different positions' do
234- code = '<template><input ...attributes type="text" placeholder="Enter text"></template>'
248+ code = '<template>' \
249+ '<input ...attributes type="text" placeholder="Enter text">' \
250+ '</template>'
235251 assert_has_token 'Operator' , code # ... operator
236252 assert_has_token 'Name.Attribute' , code # attributes, type, placeholder
237253 assert_has_token 'Literal.String' , code # "text", "Enter text"
@@ -240,14 +256,15 @@ class MyComponent extends Component {
240256 it 'lexes mixed TypeScript and template content' do
241257 code = <<~GTS
242258 import { helper } from '@ember/component/helper';
243-
244- const formatName = helper(([first, last]: [string, string]) => `${first} ${last}`);
245-
259+
260+ const formatName = helper(([first, last]: [string, string]) =>
261+ `${first} ${last}`);
262+
246263 <template>
247264 <p>{{formatName @firstName @lastName}}</p>
248265 </template>
249266 GTS
250-
267+
251268 assert_has_token 'Keyword' , code # import, const
252269 assert_has_token 'Name.Function' , code # helper
253270 assert_has_token 'Keyword.Reserved' , code # string
0 commit comments