Skip to content

Commit 67f14b7

Browse files
Copilotjanechu
authored andcommitted
Fix html template formatting to prevent test failures; add change files for CI
Co-authored-by: janechu <7559015+janechu@users.noreply.github.com>
1 parent 0f69725 commit 67f14b7

6 files changed

Lines changed: 80 additions & 110 deletions
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "none",
3+
"comment": "Enable Prettier and ESLint for spec files",
4+
"packageName": "@microsoft/fast-html",
5+
"email": "198982749+Copilot@users.noreply.github.com",
6+
"dependentChangeType": "none"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "none",
3+
"comment": "Enable Prettier and ESLint for spec files",
4+
"packageName": "@microsoft/fast-router",
5+
"email": "198982749+Copilot@users.noreply.github.com",
6+
"dependentChangeType": "none"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "none",
3+
"comment": "Enable Prettier and ESLint for spec files",
4+
"packageName": "@microsoft/fast-ssr",
5+
"email": "198982749+Copilot@users.noreply.github.com",
6+
"dependentChangeType": "none"
7+
}

packages/fast-element/src/components/element-controller.pw.spec.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1933,9 +1933,8 @@ test.describe("The ElementController", () => {
19331933
class TestElement extends FASTElement {
19341934
static definition = {
19351935
name,
1936-
template: html`
1937-
Test 2
1938-
`,
1936+
// prettier-ignore
1937+
template: html`Test 2`,
19391938
};
19401939
}
19411940
).define();

packages/fast-element/src/templating/template.pw.spec.ts

Lines changed: 53 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -120,125 +120,98 @@ test.describe("The html tag template helper", () => {
120120
const scenarios = [
121121
// string
122122
{
123-
template: html`
124-
${stringValue} end
125-
`,
123+
// prettier-ignore
124+
template: html`${stringValue} end`,
126125
result: `${FAKE.interpolation} end`,
127126
},
128127
{
129-
template: html`
130-
beginning ${stringValue} end
131-
`,
128+
// prettier-ignore
129+
template: html`beginning ${stringValue} end`,
132130
result: `beginning ${FAKE.interpolation} end`,
133131
},
134132
{
135-
template: html`
136-
beginning ${stringValue}
137-
`,
133+
// prettier-ignore
134+
template: html`beginning ${stringValue}`,
138135
result: `beginning ${FAKE.interpolation}`,
139136
},
140137
// number
141138
{
142-
template: html`
143-
${numberValue} end
144-
`,
139+
// prettier-ignore
140+
template: html`${numberValue} end`,
145141
result: `${FAKE.interpolation} end`,
146142
},
147143
{
148-
template: html`
149-
beginning ${numberValue} end
150-
`,
144+
// prettier-ignore
145+
template: html`beginning ${numberValue} end`,
151146
result: `beginning ${FAKE.interpolation} end`,
152147
},
153148
{
154-
template: html`
155-
beginning ${numberValue}
156-
`,
149+
// prettier-ignore
150+
template: html`beginning ${numberValue}`,
157151
result: `beginning ${FAKE.interpolation}`,
158152
},
159153
// expression
160154
{
161-
template: html`
162-
${x => x.value} end
163-
`,
155+
// prettier-ignore
156+
template: html`${x => x.value} end`,
164157
result: `${FAKE.interpolation} end`,
165158
expectDirectives: [HTMLBindingDirective],
166159
},
167160
{
168-
template: html`
169-
beginning ${x => x.value} end
170-
`,
161+
// prettier-ignore
162+
template: html`beginning ${x => x.value} end`,
171163
result: `beginning ${FAKE.interpolation} end`,
172164
expectDirectives: [HTMLBindingDirective],
173165
},
174166
{
175-
template: html`
176-
beginning ${x => x.value}
177-
`,
167+
// prettier-ignore
168+
template: html`beginning ${x => x.value}`,
178169
result: `beginning ${FAKE.interpolation}`,
179170
expectDirectives: [HTMLBindingDirective],
180171
},
181172
// directive
182173
{
183-
template: html`
184-
${new TestDirective()} end
185-
`,
174+
// prettier-ignore
175+
template: html`${new TestDirective()} end`,
186176
result: `${FAKE.comment} end`,
187177
expectDirectives: [TestDirective],
188178
},
189179
{
190-
template: html`
191-
beginning ${new TestDirective()} end
192-
`,
180+
// prettier-ignore
181+
template: html`beginning ${new TestDirective()} end`,
193182
result: `beginning ${FAKE.comment} end`,
194183
expectDirectives: [TestDirective],
195184
},
196185
{
197-
template: html`
198-
beginning ${new TestDirective()}
199-
`,
186+
// prettier-ignore
187+
template: html`beginning ${new TestDirective()}`,
200188
result: `beginning ${FAKE.comment}`,
201189
expectDirectives: [TestDirective],
202190
},
203191
// template
204192
{
205-
template: html`
206-
${html`
207-
sub-template
208-
`}
209-
end
210-
`,
193+
// prettier-ignore
194+
template: html`${html`sub-template`} end`,
211195
result: `${FAKE.interpolation} end`,
212196
expectDirectives: [HTMLBindingDirective],
213197
},
214198
{
215-
template: html`
216-
beginning
217-
${html`
218-
sub-template
219-
`}
220-
end
221-
`,
199+
// prettier-ignore
200+
template: html`beginning ${html`sub-template`} end`,
222201
result: `beginning ${FAKE.interpolation} end`,
223202
expectDirectives: [HTMLBindingDirective],
224203
},
225204
{
226-
template: html`
227-
beginning
228-
${html`
229-
sub-template
230-
`}
231-
`,
205+
// prettier-ignore
206+
template: html`beginning ${html`sub-template`}`,
232207
result: `beginning ${FAKE.interpolation}`,
233208
expectDirectives: [HTMLBindingDirective],
234209
},
235210
// mixed back-to-back
236211
{
237-
template: html`
238-
${stringValue}${numberValue}${x =>
239-
x.value}${new TestDirective()}
240-
end
241-
`,
212+
// prettier-ignore
213+
template: html`${stringValue}${numberValue}${
214+
x => x.value}${new TestDirective()} end`,
242215
result: `${FAKE.interpolation}${FAKE.interpolation}${FAKE.interpolation}${FAKE.comment} end`,
243216
expectDirectives: [
244217
HTMLBindingDirective,
@@ -247,12 +220,10 @@ test.describe("The html tag template helper", () => {
247220
],
248221
},
249222
{
250-
template: html`
251-
beginning
252-
${stringValue}${numberValue}${x =>
253-
x.value}${new TestDirective()}
254-
end
255-
`,
223+
// prettier-ignore
224+
template: html`beginning ${stringValue}${numberValue}${
225+
x => x.value
226+
}${new TestDirective()} end`,
256227
result: `beginning ${FAKE.interpolation}${FAKE.interpolation}${FAKE.interpolation}${FAKE.comment} end`,
257228
expectDirectives: [
258229
HTMLBindingDirective,
@@ -261,11 +232,10 @@ test.describe("The html tag template helper", () => {
261232
],
262233
},
263234
{
264-
template: html`
265-
beginning
266-
${stringValue}${numberValue}${x =>
267-
x.value}${new TestDirective()}
268-
`,
235+
// prettier-ignore
236+
template: html`beginning ${stringValue}${numberValue}${
237+
x => x.value}${new TestDirective()
238+
}`,
269239
result: `beginning ${FAKE.interpolation}${FAKE.interpolation}${FAKE.interpolation}${FAKE.comment}`,
270240
expectDirectives: [
271241
HTMLBindingDirective,
@@ -275,11 +245,10 @@ test.describe("The html tag template helper", () => {
275245
},
276246
// mixed separated
277247
{
278-
template: html`
279-
${stringValue}separator${numberValue}separator${x =>
280-
x.value}separator${new TestDirective()}
281-
end
282-
`,
248+
// prettier-ignore
249+
template: html`${stringValue}separator${numberValue}separator${
250+
x => x.value
251+
}separator${new TestDirective()} end`,
283252
// eslint-disable-next-line max-len
284253
result: `${FAKE.interpolation}separator${FAKE.interpolation}separator${FAKE.interpolation}separator${FAKE.comment} end`,
285254
expectDirectives: [
@@ -289,12 +258,10 @@ test.describe("The html tag template helper", () => {
289258
],
290259
},
291260
{
292-
template: html`
293-
beginning
294-
${stringValue}separator${numberValue}separator${x =>
295-
x.value}separator${new TestDirective()}
296-
end
297-
`,
261+
// prettier-ignore
262+
template: html`beginning ${stringValue}separator${numberValue}separator${
263+
x => x.value
264+
}separator${new TestDirective()} end`,
298265
// eslint-disable-next-line max-len
299266
result: `beginning ${FAKE.interpolation}separator${FAKE.interpolation}separator${FAKE.interpolation}separator${FAKE.comment} end`,
300267
expectDirectives: [
@@ -304,11 +271,10 @@ test.describe("The html tag template helper", () => {
304271
],
305272
},
306273
{
307-
template: html`
308-
beginning
309-
${stringValue}separator${numberValue}separator${x =>
310-
x.value}separator${new TestDirective()}
311-
`,
274+
// prettier-ignore
275+
template: html`beginning ${stringValue}separator${numberValue}separator${
276+
x => x.value
277+
}separator${new TestDirective()}`,
312278
// eslint-disable-next-line max-len
313279
result: `beginning ${FAKE.interpolation}separator${FAKE.interpolation}separator${FAKE.interpolation}separator${FAKE.comment}`,
314280
expectDirectives: [
@@ -319,8 +285,6 @@ test.describe("The html tag template helper", () => {
319285
},
320286
];
321287

322-
const x = scenarios[idx];
323-
324288
// expectTemplateEquals
325289
function expectTemplateEquals(template, expectedHTML) {
326290
if (!(template instanceof ViewTemplate)) return "not a ViewTemplate";

packages/fast-ssr/src/exports.spec.ts

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,8 @@ test.describe("fastSSR default export", () => {
7171
const { templateRenderer } = fastSSR({
7272
viewBehaviorFactoryRenderers: [renderer],
7373
});
74-
expect(
75-
consolidate(
76-
templateRenderer.render(
77-
html`
78-
<p ${new Directive("hello-world")}></p>
79-
`
80-
)
81-
)
82-
).toBe(`<p value='hello-world'></p>`);
74+
// prettier-ignore
75+
expect(consolidate(templateRenderer.render(html`<p ${new Directive("hello-world")}></p>`))).toBe(`<p value='hello-world'></p>`);
8376
});
8477
test("should support overriding pre-registered ViewBehaviorFactoryRenderer", () => {
8578
class Directive extends StatelessAttachedAttributeDirective<string> {
@@ -99,14 +92,7 @@ test.describe("fastSSR default export", () => {
9992
const { templateRenderer } = fastSSR({
10093
viewBehaviorFactoryRenderers: [renderer],
10194
});
102-
expect(
103-
consolidate(
104-
templateRenderer.render(
105-
html`
106-
<p ${ref("key")}></p>
107-
`
108-
)
109-
)
110-
).toBe(`<p ref='some-ref'></p>`);
95+
// prettier-ignore
96+
expect(consolidate(templateRenderer.render(html`<p ${ref("key")}></p>`))).toBe(`<p ref='some-ref'></p>`);
11197
});
11298
});

0 commit comments

Comments
 (0)