|
1 | 1 | import "./install-dom-shim.js"; |
2 | 2 | import { expect, test } from "@playwright/test"; |
3 | | -import * as Foundation from "@microsoft/fast-foundation"; |
4 | | -import { ElementViewTemplate, FASTElement } from "@microsoft/fast-element"; |
| 3 | +import { FASTElement, html } from "@microsoft/fast-element"; |
5 | 4 | import { createWindow } from "./dom-shim.js"; |
6 | 5 | import fastSSR from "./exports.js"; |
7 | 6 | import { uniqueElementName } from "@microsoft/fast-element/testing.js"; |
@@ -29,110 +28,20 @@ test.describe("createWindow", () => { |
29 | 28 | }); |
30 | 29 | }); |
31 | 30 |
|
32 | | -function deriveName(ctor: typeof FASTElement) { |
33 | | - const baseName = ctor.name.toLowerCase(); |
34 | | - return `fast-${baseName}`; |
35 | | -} |
36 | | - |
37 | | -const dataGrid = deriveName(Foundation.FASTDataGrid); |
38 | | -const dataGridRow = deriveName(Foundation.FASTDataGridRow); |
39 | | -const dataGridCell = deriveName(Foundation.FASTDataGridCell); |
40 | | -const anchoredRegion = deriveName(Foundation.FASTAnchoredRegion); |
41 | | -const pickerList = deriveName(Foundation.FASTPickerList); |
42 | | -const pickerListItem = deriveName(Foundation.FASTPickerListItem); |
43 | | -const pickerMenu = deriveName(Foundation.FASTPickerMenu); |
44 | | -const pickerMenuOption = deriveName(Foundation.FASTPickerMenuOption); |
45 | | -const progressRing = deriveName(Foundation.FASTProgressRing); |
46 | | - |
47 | | -const componentsAndTemplates: [typeof FASTElement, ElementViewTemplate][] = [ |
48 | | - [Foundation.FASTAccordion, Foundation.accordionTemplate()], |
49 | | - [Foundation.FASTAccordionItem, Foundation.accordionItemTemplate()], |
50 | | - [Foundation.FASTAnchor, Foundation.anchorTemplate()], |
51 | | - [Foundation.FASTAnchoredRegion, Foundation.anchoredRegionTemplate()], |
52 | | - [Foundation.FASTAvatar, Foundation.avatarTemplate()], |
53 | | - [Foundation.FASTBadge, Foundation.badgeTemplate()], |
54 | | - [Foundation.FASTBreadcrumb, Foundation.breadcrumbTemplate()], |
55 | | - [Foundation.FASTBreadcrumbItem, Foundation.breadcrumbItemTemplate()], |
56 | | - [Foundation.FASTButton, Foundation.buttonTemplate()], |
57 | | - [ |
58 | | - Foundation.FASTCalendar, |
59 | | - Foundation.calendarTemplate({ |
60 | | - dataGrid, |
61 | | - dataGridRow, |
62 | | - dataGridCell, |
63 | | - }), |
64 | | - ], |
65 | | - [Foundation.FASTCard, Foundation.cardTemplate()], |
66 | | - [Foundation.FASTCheckbox, Foundation.checkboxTemplate()], |
67 | | - [Foundation.FASTCombobox, Foundation.comboboxTemplate()], |
68 | | - [ |
69 | | - Foundation.FASTDataGrid, |
70 | | - Foundation.dataGridTemplate({ |
71 | | - dataGridRow, |
72 | | - }), |
73 | | - ], |
74 | | - [Foundation.FASTDataGridCell, Foundation.dataGridCellTemplate()], |
75 | | - [ |
76 | | - Foundation.FASTDataGridRow, |
77 | | - Foundation.dataGridRowTemplate({ |
78 | | - dataGridCell, |
79 | | - }), |
80 | | - ], |
81 | | - [Foundation.FASTDialog, Foundation.dialogTemplate()], |
82 | | - [Foundation.FASTDisclosure, Foundation.disclosureTemplate()], |
83 | | - [Foundation.FASTDivider, Foundation.dividerTemplate()], |
84 | | - [Foundation.FASTFlipper, Foundation.flipperTemplate()], |
85 | | - [Foundation.FASTHorizontalScroll, Foundation.horizontalScrollTemplate()], |
86 | | - [Foundation.FASTListbox as any as typeof FASTElement, Foundation.listboxTemplate()], |
87 | | - [Foundation.FASTListboxOption, Foundation.listboxOptionTemplate()], |
88 | | - [Foundation.FASTMenu, Foundation.menuTemplate()], |
89 | | - [Foundation.FASTMenuItem, Foundation.menuItemTemplate()], |
90 | | - [Foundation.FASTNumberField, Foundation.numberFieldTemplate()], |
91 | | - [ |
92 | | - Foundation.FASTPicker, |
93 | | - Foundation.pickerTemplate({ |
94 | | - anchoredRegion, |
95 | | - pickerList, |
96 | | - pickerListItem, |
97 | | - pickerMenu, |
98 | | - pickerMenuOption, |
99 | | - progressRing, |
100 | | - }), |
101 | | - ], |
102 | | - [Foundation.FASTPickerList, Foundation.pickerListTemplate()], |
103 | | - [Foundation.FASTPickerListItem, Foundation.pickerListItemTemplate()], |
104 | | - [Foundation.FASTPickerMenu, Foundation.pickerMenuTemplate()], |
105 | | - [Foundation.FASTPickerMenuOption, Foundation.pickerMenuOptionTemplate()], |
106 | | - [Foundation.FASTProgress, Foundation.progressTemplate()], |
107 | | - [Foundation.FASTProgressRing, Foundation.progressRingTemplate()], |
108 | | - [Foundation.FASTRadio, Foundation.radioTemplate()], |
109 | | - [Foundation.FASTRadioGroup, Foundation.radioGroupTemplate()], |
110 | | - [Foundation.FASTSearch, Foundation.searchTemplate()], |
111 | | - [Foundation.FASTSkeleton, Foundation.skeletonTemplate()], |
112 | | - [Foundation.FASTSlider, Foundation.sliderTemplate()], |
113 | | - [Foundation.FASTSliderLabel, Foundation.sliderLabelTemplate()], |
114 | | - [Foundation.FASTSwitch, Foundation.switchTemplate()], |
115 | | - [Foundation.FASTTab, Foundation.tabTemplate()], |
116 | | - [Foundation.FASTTabPanel, Foundation.tabPanelTemplate()], |
117 | | - [Foundation.FASTTabs, Foundation.tabsTemplate()], |
118 | | - [Foundation.FASTTextArea, Foundation.textAreaTemplate()], |
119 | | - [Foundation.FASTTextField, Foundation.textFieldTemplate()], |
120 | | - [Foundation.FASTToolbar, Foundation.toolbarTemplate()], |
121 | | - [Foundation.FASTTooltip,Foundation.tooltipTemplate()], |
122 | | - [Foundation.FASTTreeItem, Foundation.treeItemTemplate()], |
123 | | - [Foundation.FASTTreeView, Foundation.treeViewTemplate()], |
124 | | -]; |
125 | | - |
126 | 31 | test.describe("The DOM shim", () => { |
127 | | - componentsAndTemplates.forEach(([ctor, template]) => { |
128 | | - const name = deriveName(ctor); |
129 | | - ctor.define({ name, template }); |
130 | | - |
131 | | - test(`should support construction and connection of the ${ctor.name} component and template during SSR rendering`, () => { |
132 | | - const { templateRenderer } = fastSSR(); |
133 | | - const templateString = `<${name}></${name}>`; |
134 | | - expect(() => templateRenderer.render(templateString)).not.toThrow(); |
| 32 | + test(`should support construction and connection of a component and template during SSR rendering`, () => { |
| 33 | + class MyComponent extends FASTElement {} |
| 34 | + |
| 35 | + const name = "my-component"; |
| 36 | + |
| 37 | + MyComponent.define({ |
| 38 | + name, |
| 39 | + template: html`` |
135 | 40 | }); |
| 41 | + |
| 42 | + const { templateRenderer } = fastSSR(); |
| 43 | + const templateString = `<${name}></${name}>`; |
| 44 | + expect(() => templateRenderer.render(templateString)).not.toThrow(); |
136 | 45 | }); |
137 | 46 |
|
138 | 47 | test.describe("has a CSSStyleSheet implementation", () => { |
|
0 commit comments