@pod-os/elements 0.13.1-9efc307.0 → 0.13.1-cd22eb8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/elements.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +2 -3
- package/dist/elements/elements.esm.js +1 -1
- package/dist/elements/elements.esm.js.map +1 -1
- package/dist/esm/elements.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/types/components.d.ts +0 -13
- package/package.json +1 -1
- package/dist/cjs/test-component.cjs.entry.js +0 -15
- package/dist/cjs/test-component.cjs.entry.js.map +0 -1
- package/dist/collection/apps/pos-app-document-viewer/pos-app-document-viewer.spec.js +0 -29
- package/dist/collection/apps/pos-app-document-viewer/pos-app-document-viewer.spec.js.map +0 -1
- package/dist/collection/apps/pos-app-image-viewer/pos-app-image-viewer.spec.js +0 -29
- package/dist/collection/apps/pos-app-image-viewer/pos-app-image-viewer.spec.js.map +0 -1
- package/dist/collection/components/broken-file/BrokenFile.spec.js +0 -45
- package/dist/collection/components/broken-file/BrokenFile.spec.js.map +0 -1
- package/dist/collection/components/pos-add-literal-value/test/pos-add-literal-value.spec.js +0 -185
- package/dist/collection/components/pos-add-literal-value/test/pos-add-literal-value.spec.js.map +0 -1
- package/dist/collection/components/pos-add-new-thing/test/pos-add-new-thing.spec.js +0 -59
- package/dist/collection/components/pos-add-new-thing/test/pos-add-new-thing.spec.js.map +0 -1
- package/dist/collection/components/pos-container-contents/pos-container-contents.spec.js +0 -132
- package/dist/collection/components/pos-container-contents/pos-container-contents.spec.js.map +0 -1
- package/dist/collection/components/pos-container-contents/pos-container-item.spec.js +0 -64
- package/dist/collection/components/pos-container-contents/pos-container-item.spec.js.map +0 -1
- package/dist/collection/components/pos-container-contents/selectIconForTypes.spec.js +0 -30
- package/dist/collection/components/pos-container-contents/selectIconForTypes.spec.js.map +0 -1
- package/dist/collection/components/pos-description/pos-description.spec.js +0 -31
- package/dist/collection/components/pos-description/pos-description.spec.js.map +0 -1
- package/dist/collection/components/pos-document/pos-document.spec.js +0 -219
- package/dist/collection/components/pos-document/pos-document.spec.js.map +0 -1
- package/dist/collection/components/pos-error-toast/test/pos-error-toast.spec.js +0 -18
- package/dist/collection/components/pos-error-toast/test/pos-error-toast.spec.js.map +0 -1
- package/dist/collection/components/pos-image/pos-image.integration.spec.js +0 -124
- package/dist/collection/components/pos-image/pos-image.integration.spec.js.map +0 -1
- package/dist/collection/components/pos-image/pos-image.spec.js +0 -219
- package/dist/collection/components/pos-image/pos-image.spec.js.map +0 -1
- package/dist/collection/components/pos-label/pos-label.integration.spec.js +0 -101
- package/dist/collection/components/pos-label/pos-label.integration.spec.js.map +0 -1
- package/dist/collection/components/pos-label/pos-label.spec.js +0 -31
- package/dist/collection/components/pos-label/pos-label.spec.js.map +0 -1
- package/dist/collection/components/pos-literals/pos-literals.spec.js +0 -118
- package/dist/collection/components/pos-literals/pos-literals.spec.js.map +0 -1
- package/dist/collection/components/pos-login/pos-login.integration.spec.js +0 -35
- package/dist/collection/components/pos-login/pos-login.integration.spec.js.map +0 -1
- package/dist/collection/components/pos-login/pos-login.spec.js +0 -46
- package/dist/collection/components/pos-login/pos-login.spec.js.map +0 -1
- package/dist/collection/components/pos-navigation-bar/pos-navigation-bar.spec.js +0 -41
- package/dist/collection/components/pos-navigation-bar/pos-navigation-bar.spec.js.map +0 -1
- package/dist/collection/components/pos-new-thing-form/test/pos-new-thing-form.spec.js +0 -239
- package/dist/collection/components/pos-new-thing-form/test/pos-new-thing-form.spec.js.map +0 -1
- package/dist/collection/components/pos-picture/pos-picture.integration.spec.js +0 -79
- package/dist/collection/components/pos-picture/pos-picture.integration.spec.js.map +0 -1
- package/dist/collection/components/pos-picture/pos-picture.spec.js +0 -49
- package/dist/collection/components/pos-picture/pos-picture.spec.js.map +0 -1
- package/dist/collection/components/pos-relations/pos-relations.spec.js +0 -64
- package/dist/collection/components/pos-relations/pos-relations.spec.js.map +0 -1
- package/dist/collection/components/pos-resource/pos-resource.integration.spec.js +0 -355
- package/dist/collection/components/pos-resource/pos-resource.integration.spec.js.map +0 -1
- package/dist/collection/components/pos-resource/pos-resource.spec.js +0 -237
- package/dist/collection/components/pos-resource/pos-resource.spec.js.map +0 -1
- package/dist/collection/components/pos-reverse-relations/pos-reverse-relations.spec.js +0 -64
- package/dist/collection/components/pos-reverse-relations/pos-reverse-relations.spec.js.map +0 -1
- package/dist/collection/components/pos-rich-link/pos-rich-link.spec.js +0 -37
- package/dist/collection/components/pos-rich-link/pos-rich-link.spec.js.map +0 -1
- package/dist/collection/components/pos-select-term/test/pos-select-term.spec.js +0 -75
- package/dist/collection/components/pos-select-term/test/pos-select-term.spec.js.map +0 -1
- package/dist/collection/components/pos-subjects/pos-subjects.spec.js +0 -58
- package/dist/collection/components/pos-subjects/pos-subjects.spec.js.map +0 -1
- package/dist/collection/components/pos-type-badges/pos-type-badges.spec.js +0 -119
- package/dist/collection/components/pos-type-badges/pos-type-badges.spec.js.map +0 -1
- package/dist/collection/components/pos-type-router/pos-type-router.spec.js +0 -105
- package/dist/collection/components/pos-type-router/pos-type-router.spec.js.map +0 -1
- package/dist/collection/components/pos-type-router/selectAppForTypes.spec.js +0 -85
- package/dist/collection/components/pos-type-router/selectAppForTypes.spec.js.map +0 -1
- package/dist/collection/components/pos-value/pos-value.spec.js +0 -31
- package/dist/collection/components/pos-value/pos-value.spec.js.map +0 -1
- package/dist/collection/test/TestComponent.js +0 -4
- package/dist/collection/test/TestComponent.js.map +0 -1
- package/dist/collection/test/mockPodOS.js +0 -38
- package/dist/collection/test/mockPodOS.js.map +0 -1
- package/dist/collection/test/renderFunctionalComponent.js +0 -9
- package/dist/collection/test/renderFunctionalComponent.js.map +0 -1
- package/dist/components/test-component.d.ts +0 -11
- package/dist/components/test-component.js +0 -9
- package/dist/components/test-component.js.map +0 -1
- package/dist/elements/p-c5bcab34.entry.js +0 -2
- package/dist/elements/p-c5bcab34.entry.js.map +0 -1
- package/dist/esm/test-component.entry.js +0 -11
- package/dist/esm/test-component.entry.js.map +0 -1
- package/dist/types/test/TestComponent.d.ts +0 -2
- package/dist/types/test/mockPodOS.d.ts +0 -13
- package/dist/types/test/renderFunctionalComponent.d.ts +0 -1
|
@@ -1,239 +0,0 @@
|
|
|
1
|
-
import { newSpecPage } from "@stencil/core/testing";
|
|
2
|
-
import { fireEvent, screen } from "@testing-library/dom";
|
|
3
|
-
import { when } from "jest-when";
|
|
4
|
-
import { mockPodOS } from "../../../test/mockPodOS";
|
|
5
|
-
import { PosNewThingForm } from "../pos-new-thing-form";
|
|
6
|
-
describe('pos-new-thing-form', () => {
|
|
7
|
-
it('renders a form', async () => {
|
|
8
|
-
const page = await newSpecPage({
|
|
9
|
-
components: [PosNewThingForm],
|
|
10
|
-
html: `<pos-new-thing-form reference-uri="https://pod.test/container/"></pos-new-thing-form>`,
|
|
11
|
-
supportsShadowDom: false,
|
|
12
|
-
});
|
|
13
|
-
expect(page.root).toEqualHtml(`
|
|
14
|
-
<pos-new-thing-form reference-uri="https://pod.test/container/">
|
|
15
|
-
<form method="dialog">
|
|
16
|
-
<label htmlFor="type">
|
|
17
|
-
Type
|
|
18
|
-
</label>
|
|
19
|
-
<pos-select-term id="type" placeholder=""></pos-select-term>
|
|
20
|
-
<label htmlFor="name">
|
|
21
|
-
Name
|
|
22
|
-
</label>
|
|
23
|
-
<input id="name" type="text">
|
|
24
|
-
<input id="create" type="submit" value="Create" disabled>
|
|
25
|
-
</form>
|
|
26
|
-
</pos-new-thing-form>`);
|
|
27
|
-
});
|
|
28
|
-
describe('enabling and disabling the create button', () => {
|
|
29
|
-
it('is disabled initially', async () => {
|
|
30
|
-
await newSpecPage({
|
|
31
|
-
components: [PosNewThingForm],
|
|
32
|
-
html: `<pos-new-thing-form reference-uri="https://pod.test/container/"></pos-new-thing-form>`,
|
|
33
|
-
supportsShadowDom: false,
|
|
34
|
-
});
|
|
35
|
-
const button = screen.getByDisplayValue('Create');
|
|
36
|
-
expect(button.disabled).toBe(true);
|
|
37
|
-
});
|
|
38
|
-
it('is still disabled after selecting a term', async () => {
|
|
39
|
-
// given
|
|
40
|
-
const page = await newSpecPage({
|
|
41
|
-
components: [PosNewThingForm],
|
|
42
|
-
html: `<pos-new-thing-form reference-uri="https://pod.test/container/"></pos-new-thing-form>`,
|
|
43
|
-
supportsShadowDom: false,
|
|
44
|
-
});
|
|
45
|
-
const button = screen.getByDisplayValue('Create');
|
|
46
|
-
// when user selects a term
|
|
47
|
-
const termSelect = page.root.querySelector('pos-select-term');
|
|
48
|
-
fireEvent(termSelect, new CustomEvent('pod-os:term-selected', { detail: { uri: 'https://schema.org/description' } }));
|
|
49
|
-
// then the button is enabled
|
|
50
|
-
expect(button.disabled).toBe(true);
|
|
51
|
-
});
|
|
52
|
-
it('is still disabled after entering a name', async () => {
|
|
53
|
-
// given
|
|
54
|
-
const page = await newSpecPage({
|
|
55
|
-
components: [PosNewThingForm],
|
|
56
|
-
html: `<pos-new-thing-form reference-uri="https://pod.test/container/"></pos-new-thing-form>`,
|
|
57
|
-
supportsShadowDom: false,
|
|
58
|
-
});
|
|
59
|
-
const os = mockPodOS();
|
|
60
|
-
await page.rootInstance.receivePodOs(os);
|
|
61
|
-
// when user fills in a name
|
|
62
|
-
const nameField = page.root.querySelector('input[type=text]');
|
|
63
|
-
fireEvent.input(nameField, { target: { value: 'New Thing' } });
|
|
64
|
-
await page.waitForChanges();
|
|
65
|
-
// then the button is disabled
|
|
66
|
-
const button = screen.getByDisplayValue('Create');
|
|
67
|
-
expect(button.disabled).toBe(true);
|
|
68
|
-
});
|
|
69
|
-
it('is enabled after a term has been selected and a name typed', async () => {
|
|
70
|
-
// given
|
|
71
|
-
const page = await newSpecPage({
|
|
72
|
-
components: [PosNewThingForm],
|
|
73
|
-
html: `<pos-new-thing-form reference-uri="https://pod.test/container/"></pos-new-thing-form>`,
|
|
74
|
-
supportsShadowDom: false,
|
|
75
|
-
});
|
|
76
|
-
const os = mockPodOS();
|
|
77
|
-
await page.rootInstance.receivePodOs(os);
|
|
78
|
-
// when user selects a term
|
|
79
|
-
const termSelect = page.root.querySelector('pos-select-term');
|
|
80
|
-
fireEvent(termSelect, new CustomEvent('pod-os:term-selected', { detail: { uri: 'https://schema.org/description' } }));
|
|
81
|
-
// and fills in a name
|
|
82
|
-
const nameField = page.root.querySelector('input[type=text]');
|
|
83
|
-
fireEvent.input(nameField, { target: { value: 'New Thing' } });
|
|
84
|
-
await page.waitForChanges();
|
|
85
|
-
// then the button is enabled
|
|
86
|
-
const button = screen.getByDisplayValue('Create');
|
|
87
|
-
expect(button.disabled).toBe(false);
|
|
88
|
-
});
|
|
89
|
-
it('is enabled when name is typed and then a term is selected', async () => {
|
|
90
|
-
// given
|
|
91
|
-
const page = await newSpecPage({
|
|
92
|
-
components: [PosNewThingForm],
|
|
93
|
-
html: `<pos-new-thing-form reference-uri="https://pod.test/container/"></pos-new-thing-form>`,
|
|
94
|
-
supportsShadowDom: false,
|
|
95
|
-
});
|
|
96
|
-
const os = mockPodOS();
|
|
97
|
-
await page.rootInstance.receivePodOs(os);
|
|
98
|
-
// when user fills in a name
|
|
99
|
-
const nameField = page.root.querySelector('input[type=text]');
|
|
100
|
-
fireEvent.input(nameField, { target: { value: 'New Thing' } });
|
|
101
|
-
// and after that selects a term
|
|
102
|
-
const termSelect = page.root.querySelector('pos-select-term');
|
|
103
|
-
fireEvent(termSelect, new CustomEvent('pod-os:term-selected', { detail: { uri: 'https://schema.org/description' } }));
|
|
104
|
-
await page.waitForChanges();
|
|
105
|
-
// then the button is enabled
|
|
106
|
-
const button = screen.getByDisplayValue('Create');
|
|
107
|
-
expect(button.disabled).toBe(false);
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
it('shows the URI of the new thing after typing a name', async () => {
|
|
111
|
-
const page = await newSpecPage({
|
|
112
|
-
components: [PosNewThingForm],
|
|
113
|
-
html: `<pos-new-thing-form reference-uri="https://pod.test/container/"></pos-new-thing-form>`,
|
|
114
|
-
supportsShadowDom: false,
|
|
115
|
-
});
|
|
116
|
-
const os = mockPodOS();
|
|
117
|
-
when(os.proposeUriForNewThing)
|
|
118
|
-
.calledWith('https://pod.test/container/', 'New Thing')
|
|
119
|
-
.mockReturnValue('https://pod.test/container/new-thing#it');
|
|
120
|
-
await page.rootInstance.receivePodOs(os);
|
|
121
|
-
const nameField = page.root.querySelector('input[type=text]');
|
|
122
|
-
fireEvent.input(nameField, { target: { value: 'New Thing' } });
|
|
123
|
-
await page.waitForChanges();
|
|
124
|
-
expect(os.proposeUriForNewThing).toHaveBeenCalledWith('https://pod.test/container/', 'New Thing');
|
|
125
|
-
expect(page.root).toEqualHtml(`
|
|
126
|
-
<pos-new-thing-form reference-uri="https://pod.test/container/">
|
|
127
|
-
<form method="dialog">
|
|
128
|
-
<label htmlFor="type">
|
|
129
|
-
Type
|
|
130
|
-
</label>
|
|
131
|
-
<pos-select-term id="type" placeholder=""></pos-select-term>
|
|
132
|
-
<label htmlFor="name">
|
|
133
|
-
Name
|
|
134
|
-
</label>
|
|
135
|
-
<input id="name" type="text" value="New Thing">
|
|
136
|
-
<div id="new-uri" title="This will be the URI of the new thing">
|
|
137
|
-
https://pod.test/container/new-thing#it
|
|
138
|
-
</div>
|
|
139
|
-
<input id="create" type="submit" value="Create" disabled />
|
|
140
|
-
</form>
|
|
141
|
-
</pos-new-thing-form>`);
|
|
142
|
-
});
|
|
143
|
-
describe('submitting form', () => {
|
|
144
|
-
describe('successfully', () => {
|
|
145
|
-
let page;
|
|
146
|
-
let os;
|
|
147
|
-
let linkEventListener;
|
|
148
|
-
beforeEach(async () => {
|
|
149
|
-
// given
|
|
150
|
-
page = await newSpecPage({
|
|
151
|
-
components: [PosNewThingForm],
|
|
152
|
-
html: `<pos-new-thing-form reference-uri="https://pod.test/container/"></pos-new-thing-form>`,
|
|
153
|
-
supportsShadowDom: false,
|
|
154
|
-
});
|
|
155
|
-
os = mockPodOS();
|
|
156
|
-
when(os.proposeUriForNewThing)
|
|
157
|
-
.calledWith('https://pod.test/container/', 'New Thing')
|
|
158
|
-
.mockReturnValue('https://pod.test/container/new-thing#it');
|
|
159
|
-
await page.rootInstance.receivePodOs(os);
|
|
160
|
-
// and the page listens for pod-os:link events
|
|
161
|
-
linkEventListener = jest.fn();
|
|
162
|
-
page.root.addEventListener('pod-os:link', linkEventListener);
|
|
163
|
-
// when user selects a term and adds a name
|
|
164
|
-
const termSelect = page.root.querySelector('pos-select-term');
|
|
165
|
-
fireEvent(termSelect, new CustomEvent('pod-os:term-selected', { detail: { uri: 'https://schema.org/Thing' } }));
|
|
166
|
-
const nameField = page.root.querySelector('input[type=text]');
|
|
167
|
-
fireEvent.input(nameField, { target: { value: 'New Thing' } });
|
|
168
|
-
await page.waitForChanges();
|
|
169
|
-
// and submits the form
|
|
170
|
-
const form = page.root.querySelector('form');
|
|
171
|
-
fireEvent.submit(form);
|
|
172
|
-
await page.waitForChanges();
|
|
173
|
-
});
|
|
174
|
-
it('calls addNewThing', () => {
|
|
175
|
-
expect(os.addNewThing).toHaveBeenCalledWith('https://pod.test/container/new-thing#it', 'New Thing', 'https://schema.org/Thing');
|
|
176
|
-
});
|
|
177
|
-
it('redirects to the new thing', () => {
|
|
178
|
-
expect(linkEventListener).toHaveBeenCalledWith(expect.objectContaining({
|
|
179
|
-
detail: 'https://pod.test/container/new-thing#it',
|
|
180
|
-
}));
|
|
181
|
-
});
|
|
182
|
-
it('resets the form', async () => {
|
|
183
|
-
expect(page.rootInstance.name).toBe('');
|
|
184
|
-
expect(page.rootInstance.newUri).toBe('');
|
|
185
|
-
expect(page.rootInstance.selectedTypeUri).toBe('');
|
|
186
|
-
});
|
|
187
|
-
});
|
|
188
|
-
describe('with error', () => {
|
|
189
|
-
let page;
|
|
190
|
-
let os;
|
|
191
|
-
let linkEventListener;
|
|
192
|
-
let errorEventListener;
|
|
193
|
-
beforeEach(async () => {
|
|
194
|
-
// given
|
|
195
|
-
page = await newSpecPage({
|
|
196
|
-
components: [PosNewThingForm],
|
|
197
|
-
html: `<pos-new-thing-form reference-uri="https://pod.test/container/"></pos-new-thing-form>`,
|
|
198
|
-
supportsShadowDom: false,
|
|
199
|
-
});
|
|
200
|
-
os = mockPodOS();
|
|
201
|
-
when(os.proposeUriForNewThing)
|
|
202
|
-
.calledWith('https://pod.test/container/', 'New Thing')
|
|
203
|
-
.mockReturnValue('https://pod.test/container/new-thing#it');
|
|
204
|
-
when(os.addNewThing).mockRejectedValue(new Error('simulated error for test'));
|
|
205
|
-
await page.rootInstance.receivePodOs(os);
|
|
206
|
-
// and the page listens for pod-os:link events
|
|
207
|
-
linkEventListener = jest.fn();
|
|
208
|
-
page.root.addEventListener('pod-os:link', linkEventListener);
|
|
209
|
-
// and the page listens for pod-os:error events
|
|
210
|
-
errorEventListener = jest.fn();
|
|
211
|
-
page.root.addEventListener('pod-os:error', errorEventListener);
|
|
212
|
-
// when user selects a term and adds a name
|
|
213
|
-
const termSelect = page.root.querySelector('pos-select-term');
|
|
214
|
-
fireEvent(termSelect, new CustomEvent('pod-os:term-selected', { detail: { uri: 'https://schema.org/Thing' } }));
|
|
215
|
-
const nameField = page.root.querySelector('input[type=text]');
|
|
216
|
-
fireEvent.input(nameField, { target: { value: 'New Thing' } });
|
|
217
|
-
await page.waitForChanges();
|
|
218
|
-
// and submits the form
|
|
219
|
-
const form = page.root.querySelector('form');
|
|
220
|
-
fireEvent.submit(form);
|
|
221
|
-
await page.waitForChanges();
|
|
222
|
-
});
|
|
223
|
-
it('emits an error event', () => {
|
|
224
|
-
expect(errorEventListener).toHaveBeenCalledWith(expect.objectContaining({
|
|
225
|
-
detail: new Error('simulated error for test'),
|
|
226
|
-
}));
|
|
227
|
-
});
|
|
228
|
-
it('does not redirect', () => {
|
|
229
|
-
expect(linkEventListener).not.toHaveBeenCalled();
|
|
230
|
-
});
|
|
231
|
-
it('does not reset the form', () => {
|
|
232
|
-
expect(page.rootInstance.name).toBe('New Thing');
|
|
233
|
-
expect(page.rootInstance.newUri).toBe('https://pod.test/container/new-thing#it');
|
|
234
|
-
expect(page.rootInstance.selectedTypeUri).toBe('https://schema.org/Thing');
|
|
235
|
-
});
|
|
236
|
-
});
|
|
237
|
-
});
|
|
238
|
-
});
|
|
239
|
-
//# sourceMappingURL=pos-new-thing-form.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pos-new-thing-form.spec.js","sourceRoot":"","sources":["../../../../../src/components/pos-new-thing-form/test/pos-new-thing-form.spec.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;EAClC,EAAE,CAAC,gBAAgB,EAAE,KAAK,IAAI,EAAE;IAC9B,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC;MAC7B,UAAU,EAAE,CAAC,eAAe,CAAC;MAC7B,IAAI,EAAE,uFAAuF;MAC7F,iBAAiB,EAAE,KAAK;KACzB,CAAC,CAAC;IAEH,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,WAAW,CAC3B;;;;;;;;;;;;;8BAawB,CACzB,CAAC;EACJ,CAAC,CAAC,CAAC;EAEH,QAAQ,CAAC,0CAA0C,EAAE,GAAG,EAAE;IACxD,EAAE,CAAC,uBAAuB,EAAE,KAAK,IAAI,EAAE;MACrC,MAAM,WAAW,CAAC;QAChB,UAAU,EAAE,CAAC,eAAe,CAAC;QAC7B,IAAI,EAAE,uFAAuF;QAC7F,iBAAiB,EAAE,KAAK;OACzB,CAAC,CAAC;MACH,MAAM,MAAM,GAAsB,MAAM,CAAC,iBA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AC,CAAC,CAAC;MAEH,EAAE,CAAC,yBAAyB,EAAE,GAAG,EAAE;QACjC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACjD,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,yCAAyC,CAAC,CAAC;QACjF,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;MAC7E,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;EACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { PodOS } from '@pod-os/core';\nimport { newSpecPage } from '@stencil/core/testing';\nimport { fireEvent, screen } from '@testing-library/dom';\nimport { when } from 'jest-when';\nimport { mockPodOS } from '../../../test/mockPodOS';\nimport { PosNewThingForm } from '../pos-new-thing-form';\n\ndescribe('pos-new-thing-form', () => {\n it('renders a form', async () => {\n const page = await newSpecPage({\n components: [PosNewThingForm],\n html: `<pos-new-thing-form reference-uri=\"https://pod.test/container/\"></pos-new-thing-form>`,\n supportsShadowDom: false,\n });\n\n expect(page.root).toEqualHtml(\n `\n <pos-new-thing-form reference-uri=\"https://pod.test/container/\">\n <form method=\"dialog\">\n <label htmlFor=\"type\">\n Type\n </label>\n <pos-select-term id=\"type\" placeholder=\"\"></pos-select-term>\n <label htmlFor=\"name\">\n Name\n </label>\n <input id=\"name\" type=\"text\">\n <input id=\"create\" type=\"submit\" value=\"Create\" disabled>\n </form>\n </pos-new-thing-form>`,\n );\n });\n\n describe('enabling and disabling the create button', () => {\n it('is disabled initially', async () => {\n await newSpecPage({\n components: [PosNewThingForm],\n html: `<pos-new-thing-form reference-uri=\"https://pod.test/container/\"></pos-new-thing-form>`,\n supportsShadowDom: false,\n });\n const button: HTMLButtonElement = screen.getByDisplayValue('Create');\n\n expect(button.disabled).toBe(true);\n });\n\n it('is still disabled after selecting a term', async () => {\n // given\n const page = await newSpecPage({\n components: [PosNewThingForm],\n html: `<pos-new-thing-form reference-uri=\"https://pod.test/container/\"></pos-new-thing-form>`,\n supportsShadowDom: false,\n });\n const button: HTMLButtonElement = screen.getByDisplayValue('Create');\n\n // when user selects a term\n const termSelect = page.root.querySelector('pos-select-term');\n fireEvent(\n termSelect,\n new CustomEvent('pod-os:term-selected', { detail: { uri: 'https://schema.org/description' } }),\n );\n\n // then the button is enabled\n expect(button.disabled).toBe(true);\n });\n\n it('is still disabled after entering a name', async () => {\n // given\n const page = await newSpecPage({\n components: [PosNewThingForm],\n html: `<pos-new-thing-form reference-uri=\"https://pod.test/container/\"></pos-new-thing-form>`,\n supportsShadowDom: false,\n });\n\n const os = mockPodOS();\n await page.rootInstance.receivePodOs(os);\n\n // when user fills in a name\n const nameField = page.root.querySelector('input[type=text]');\n fireEvent.input(nameField, { target: { value: 'New Thing' } });\n await page.waitForChanges();\n\n // then the button is disabled\n const button: HTMLButtonElement = screen.getByDisplayValue('Create');\n expect(button.disabled).toBe(true);\n });\n\n it('is enabled after a term has been selected and a name typed', async () => {\n // given\n const page = await newSpecPage({\n components: [PosNewThingForm],\n html: `<pos-new-thing-form reference-uri=\"https://pod.test/container/\"></pos-new-thing-form>`,\n supportsShadowDom: false,\n });\n const os = mockPodOS();\n await page.rootInstance.receivePodOs(os);\n\n // when user selects a term\n const termSelect = page.root.querySelector('pos-select-term');\n fireEvent(\n termSelect,\n new CustomEvent('pod-os:term-selected', { detail: { uri: 'https://schema.org/description' } }),\n );\n\n // and fills in a name\n const nameField = page.root.querySelector('input[type=text]');\n fireEvent.input(nameField, { target: { value: 'New Thing' } });\n await page.waitForChanges();\n\n // then the button is enabled\n const button: HTMLButtonElement = screen.getByDisplayValue('Create');\n expect(button.disabled).toBe(false);\n });\n\n it('is enabled when name is typed and then a term is selected', async () => {\n // given\n const page = await newSpecPage({\n components: [PosNewThingForm],\n html: `<pos-new-thing-form reference-uri=\"https://pod.test/container/\"></pos-new-thing-form>`,\n supportsShadowDom: false,\n });\n const os = mockPodOS();\n await page.rootInstance.receivePodOs(os);\n\n // when user fills in a name\n const nameField = page.root.querySelector('input[type=text]');\n fireEvent.input(nameField, { target: { value: 'New Thing' } });\n\n // and after that selects a term\n const termSelect = page.root.querySelector('pos-select-term');\n fireEvent(\n termSelect,\n new CustomEvent('pod-os:term-selected', { detail: { uri: 'https://schema.org/description' } }),\n );\n await page.waitForChanges();\n\n // then the button is enabled\n const button: HTMLButtonElement = screen.getByDisplayValue('Create');\n expect(button.disabled).toBe(false);\n });\n });\n\n it('shows the URI of the new thing after typing a name', async () => {\n const page = await newSpecPage({\n components: [PosNewThingForm],\n html: `<pos-new-thing-form reference-uri=\"https://pod.test/container/\"></pos-new-thing-form>`,\n supportsShadowDom: false,\n });\n\n const os = mockPodOS();\n when(os.proposeUriForNewThing)\n .calledWith('https://pod.test/container/', 'New Thing')\n .mockReturnValue('https://pod.test/container/new-thing#it');\n await page.rootInstance.receivePodOs(os);\n\n const nameField = page.root.querySelector('input[type=text]');\n fireEvent.input(nameField, { target: { value: 'New Thing' } });\n\n await page.waitForChanges();\n\n expect(os.proposeUriForNewThing).toHaveBeenCalledWith('https://pod.test/container/', 'New Thing');\n\n expect(page.root).toEqualHtml(\n `\n <pos-new-thing-form reference-uri=\"https://pod.test/container/\">\n <form method=\"dialog\">\n <label htmlFor=\"type\">\n Type\n </label>\n <pos-select-term id=\"type\" placeholder=\"\"></pos-select-term>\n <label htmlFor=\"name\">\n Name\n </label>\n <input id=\"name\" type=\"text\" value=\"New Thing\">\n <div id=\"new-uri\" title=\"This will be the URI of the new thing\">\n https://pod.test/container/new-thing#it\n </div>\n <input id=\"create\" type=\"submit\" value=\"Create\" disabled />\n </form>\n </pos-new-thing-form>`,\n );\n });\n\n describe('submitting form', () => {\n describe('successfully', () => {\n let page;\n let os;\n let linkEventListener;\n\n beforeEach(async () => {\n // given\n page = await newSpecPage({\n components: [PosNewThingForm],\n html: `<pos-new-thing-form reference-uri=\"https://pod.test/container/\"></pos-new-thing-form>`,\n supportsShadowDom: false,\n });\n\n os = mockPodOS();\n when(os.proposeUriForNewThing)\n .calledWith('https://pod.test/container/', 'New Thing')\n .mockReturnValue('https://pod.test/container/new-thing#it');\n await page.rootInstance.receivePodOs(os);\n\n // and the page listens for pod-os:link events\n linkEventListener = jest.fn();\n page.root.addEventListener('pod-os:link', linkEventListener);\n\n // when user selects a term and adds a name\n const termSelect = page.root.querySelector('pos-select-term');\n fireEvent(termSelect, new CustomEvent('pod-os:term-selected', { detail: { uri: 'https://schema.org/Thing' } }));\n\n const nameField = page.root.querySelector('input[type=text]');\n fireEvent.input(nameField, { target: { value: 'New Thing' } });\n\n await page.waitForChanges();\n\n // and submits the form\n const form: HTMLFormElement = page.root.querySelector('form');\n fireEvent.submit(form);\n await page.waitForChanges();\n });\n\n it('calls addNewThing', () => {\n expect(os.addNewThing).toHaveBeenCalledWith(\n 'https://pod.test/container/new-thing#it',\n 'New Thing',\n 'https://schema.org/Thing',\n );\n });\n\n it('redirects to the new thing', () => {\n expect(linkEventListener).toHaveBeenCalledWith(\n expect.objectContaining({\n detail: 'https://pod.test/container/new-thing#it',\n }),\n );\n });\n\n it('resets the form', async () => {\n expect(page.rootInstance.name).toBe('');\n expect(page.rootInstance.newUri).toBe('');\n expect(page.rootInstance.selectedTypeUri).toBe('');\n });\n });\n\n describe('with error', () => {\n let page;\n let os: Partial<PodOS>;\n let linkEventListener;\n let errorEventListener;\n\n beforeEach(async () => {\n // given\n page = await newSpecPage({\n components: [PosNewThingForm],\n html: `<pos-new-thing-form reference-uri=\"https://pod.test/container/\"></pos-new-thing-form>`,\n supportsShadowDom: false,\n });\n\n os = mockPodOS() as unknown as PodOS;\n when(os.proposeUriForNewThing)\n .calledWith('https://pod.test/container/', 'New Thing')\n .mockReturnValue('https://pod.test/container/new-thing#it');\n when(os.addNewThing).mockRejectedValue(new Error('simulated error for test'));\n await page.rootInstance.receivePodOs(os);\n\n // and the page listens for pod-os:link events\n linkEventListener = jest.fn();\n page.root.addEventListener('pod-os:link', linkEventListener);\n\n // and the page listens for pod-os:error events\n errorEventListener = jest.fn();\n page.root.addEventListener('pod-os:error', errorEventListener);\n\n // when user selects a term and adds a name\n const termSelect = page.root.querySelector('pos-select-term');\n fireEvent(termSelect, new CustomEvent('pod-os:term-selected', { detail: { uri: 'https://schema.org/Thing' } }));\n\n const nameField = page.root.querySelector('input[type=text]');\n fireEvent.input(nameField, { target: { value: 'New Thing' } });\n\n await page.waitForChanges();\n\n // and submits the form\n const form: HTMLFormElement = page.root.querySelector('form');\n fireEvent.submit(form);\n await page.waitForChanges();\n });\n\n it('emits an error event', () => {\n expect(errorEventListener).toHaveBeenCalledWith(\n expect.objectContaining({\n detail: new Error('simulated error for test'),\n }),\n );\n });\n\n it('does not redirect', () => {\n expect(linkEventListener).not.toHaveBeenCalled();\n });\n\n it('does not reset the form', () => {\n expect(page.rootInstance.name).toBe('New Thing');\n expect(page.rootInstance.newUri).toBe('https://pod.test/container/new-thing#it');\n expect(page.rootInstance.selectedTypeUri).toBe('https://schema.org/Thing');\n });\n });\n });\n});\n"]}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { newSpecPage } from "@stencil/core/testing";
|
|
2
|
-
import { mockPodOS } from "../../test/mockPodOS";
|
|
3
|
-
import { PosApp } from "../pos-app/pos-app";
|
|
4
|
-
import { PosResource } from "../pos-resource/pos-resource";
|
|
5
|
-
import { PosPicture } from "./pos-picture";
|
|
6
|
-
import { when } from "jest-when";
|
|
7
|
-
describe('pos-picture', () => {
|
|
8
|
-
it('renders nothing while loading resource', async () => {
|
|
9
|
-
const os = mockPodOS();
|
|
10
|
-
const loadingPromise = new Promise(resolve => setTimeout(resolve, 1));
|
|
11
|
-
when(os.fetch).calledWith('https://resource.test').mockReturnValue(loadingPromise);
|
|
12
|
-
const page = await newSpecPage({
|
|
13
|
-
components: [PosApp, PosResource, PosPicture],
|
|
14
|
-
html: `<pos-app>
|
|
15
|
-
<pos-resource uri="https://resource.test">
|
|
16
|
-
<pos-picture />
|
|
17
|
-
</pos-resource>
|
|
18
|
-
</pos-app>`,
|
|
19
|
-
});
|
|
20
|
-
const picture = page.root.querySelector('pos-picture');
|
|
21
|
-
expect(picture).toEqualHtml(`
|
|
22
|
-
<pos-picture>
|
|
23
|
-
<mock:shadow-root></mock:shadow-root>
|
|
24
|
-
</pos-picture>
|
|
25
|
-
`);
|
|
26
|
-
await loadingPromise;
|
|
27
|
-
});
|
|
28
|
-
it('renders pos-image after successfully loading resource', async () => {
|
|
29
|
-
const os = mockPodOS();
|
|
30
|
-
const loadingPromise = new Promise(resolve => setTimeout(resolve, 1));
|
|
31
|
-
when(os.fetch).calledWith('https://resource.test').mockReturnValue(loadingPromise);
|
|
32
|
-
when(os.store.get)
|
|
33
|
-
.calledWith('https://resource.test')
|
|
34
|
-
.mockReturnValue({
|
|
35
|
-
label: () => 'The resource',
|
|
36
|
-
picture: () => ({
|
|
37
|
-
url: 'https://resource.test/picture.png',
|
|
38
|
-
}),
|
|
39
|
-
});
|
|
40
|
-
const page = await newSpecPage({
|
|
41
|
-
components: [PosApp, PosResource, PosPicture],
|
|
42
|
-
html: `<pos-app>
|
|
43
|
-
<pos-resource uri="https://resource.test">
|
|
44
|
-
<pos-picture />
|
|
45
|
-
</pos-resource>
|
|
46
|
-
</pos-app>`,
|
|
47
|
-
});
|
|
48
|
-
await loadingPromise;
|
|
49
|
-
await page.waitForChanges();
|
|
50
|
-
const picture = page.root.querySelector('pos-picture');
|
|
51
|
-
expect(picture).toEqualHtml(`
|
|
52
|
-
<pos-picture>
|
|
53
|
-
<mock:shadow-root>
|
|
54
|
-
<pos-image src="https://resource.test/picture.png" alt="The resource" />
|
|
55
|
-
</mock:shadow-root>
|
|
56
|
-
</pos-picture>
|
|
57
|
-
`);
|
|
58
|
-
});
|
|
59
|
-
it('renders nothing when resource loading failed', async () => {
|
|
60
|
-
const os = mockPodOS();
|
|
61
|
-
const rejectedPromise = Promise.reject(new Error('not found'));
|
|
62
|
-
when(os.fetch).calledWith('https://resource.test').mockReturnValue(rejectedPromise);
|
|
63
|
-
const page = await newSpecPage({
|
|
64
|
-
components: [PosApp, PosResource, PosPicture],
|
|
65
|
-
html: `<pos-app>
|
|
66
|
-
<pos-resource uri="https://resource.test">
|
|
67
|
-
<pos-picture />
|
|
68
|
-
</pos-resource>
|
|
69
|
-
</pos-app>`,
|
|
70
|
-
});
|
|
71
|
-
const picture = page.root.querySelector('pos-picture');
|
|
72
|
-
expect(picture).toEqualHtml(`
|
|
73
|
-
<pos-picture>
|
|
74
|
-
<mock:shadow-root></mock:shadow-root>
|
|
75
|
-
</pos-picture>
|
|
76
|
-
`);
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
//# sourceMappingURL=pos-picture.integration.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pos-picture.integration.spec.js","sourceRoot":"","sources":["../../../../src/components/pos-picture/pos-picture.integration.spec.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;EAC3B,EAAE,CAAC,wCAAwC,EAAE,KAAK,IAAI,EAAE;IACtD,MAAM,EAAE,GAAG,SAAS,EAAE,CAAC;IACvB,MAAM,cAAc,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;IACtE,IAAI,CAAC,EAAE,CAA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,CAAC,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;IACvD,MAAM,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC;;;;;;KAM3B,CAAC,CAAC;EACL,CAAC,CAAC,CAAC;EAEH,EAAE,CAAC,8CAA8C,EAAE,KAAK,IAAI,EAAE;IAC5D,MAAM,EAAE,GAAG,SAAS,EAAE,CAAC;IACvB,MAAM,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC;IAC/D,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,UAAU,CAAC,uBAAuB,CAAC,CAAC,eAAe,CAAC,eAAe,CAAC,CAAC;IACpF,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC;MAC7B,UAAU,EAAE,CAAC,MAAM,EAAE,WAAW,EAAE,UAAU,CAAC;MAC7C,IAAI,EAAE;;;;mBAIO;KACd,CAAC,CAAC;IACH,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;IACvD,MAAM,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC;;;;KAI3B,CAAC,CAAC;EACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { newSpecPage } from '@stencil/core/testing';\nimport { mockPodOS } from '../../test/mockPodOS';\nimport { PosApp } from '../pos-app/pos-app';\nimport { PosResource } from '../pos-resource/pos-resource';\nimport { PosPicture } from './pos-picture';\nimport { when } from 'jest-when';\n\ndescribe('pos-picture', () => {\n it('renders nothing while loading resource', async () => {\n const os = mockPodOS();\n const loadingPromise = new Promise(resolve => setTimeout(resolve, 1));\n when(os.fetch).calledWith('https://resource.test').mockReturnValue(loadingPromise);\n const page = await newSpecPage({\n components: [PosApp, PosResource, PosPicture],\n html: `<pos-app>\n <pos-resource uri=\"https://resource.test\">\n <pos-picture />\n </pos-resource>\n </pos-app>`,\n });\n const picture = page.root.querySelector('pos-picture');\n expect(picture).toEqualHtml(`\n <pos-picture>\n <mock:shadow-root></mock:shadow-root>\n </pos-picture>\n `);\n await loadingPromise;\n });\n\n it('renders pos-image after successfully loading resource', async () => {\n const os = mockPodOS();\n const loadingPromise = new Promise(resolve => setTimeout(resolve, 1));\n when(os.fetch).calledWith('https://resource.test').mockReturnValue(loadingPromise);\n when(os.store.get)\n .calledWith('https://resource.test')\n .mockReturnValue({\n label: () => 'The resource',\n picture: () => ({\n url: 'https://resource.test/picture.png',\n }),\n });\n const page = await newSpecPage({\n components: [PosApp, PosResource, PosPicture],\n html: `<pos-app>\n <pos-resource uri=\"https://resource.test\">\n <pos-picture />\n </pos-resource>\n </pos-app>`,\n });\n await loadingPromise;\n await page.waitForChanges();\n const picture = page.root.querySelector('pos-picture');\n expect(picture).toEqualHtml(`\n <pos-picture>\n <mock:shadow-root>\n <pos-image src=\"https://resource.test/picture.png\" alt=\"The resource\" />\n </mock:shadow-root>\n </pos-picture>\n `);\n });\n\n it('renders nothing when resource loading failed', async () => {\n const os = mockPodOS();\n const rejectedPromise = Promise.reject(new Error('not found'));\n when(os.fetch).calledWith('https://resource.test').mockReturnValue(rejectedPromise);\n const page = await newSpecPage({\n components: [PosApp, PosResource, PosPicture],\n html: `<pos-app>\n <pos-resource uri=\"https://resource.test\">\n <pos-picture />\n </pos-resource>\n </pos-app>`,\n });\n const picture = page.root.querySelector('pos-picture');\n expect(picture).toEqualHtml(`\n <pos-picture>\n <mock:shadow-root></mock:shadow-root>\n </pos-picture>\n `);\n });\n});\n"]}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { newSpecPage } from "@stencil/core/testing";
|
|
2
|
-
import { PosPicture } from "./pos-picture";
|
|
3
|
-
describe('pos-picture', () => {
|
|
4
|
-
it('is empty initially', async () => {
|
|
5
|
-
const page = await newSpecPage({
|
|
6
|
-
components: [PosPicture],
|
|
7
|
-
html: `<pos-picture />`,
|
|
8
|
-
});
|
|
9
|
-
expect(page.root).toEqualHtml(`
|
|
10
|
-
<pos-picture>
|
|
11
|
-
<mock:shadow-root></mock:shadow-root>
|
|
12
|
-
</pos-picture>
|
|
13
|
-
`);
|
|
14
|
-
});
|
|
15
|
-
it('renders pos-image depicting resource', async () => {
|
|
16
|
-
const page = await newSpecPage({
|
|
17
|
-
components: [PosPicture],
|
|
18
|
-
html: `<pos-picture />`,
|
|
19
|
-
});
|
|
20
|
-
await page.rootInstance.receiveResource({
|
|
21
|
-
label: () => 'a picture',
|
|
22
|
-
picture: () => ({
|
|
23
|
-
url: 'https://resource.test/picture.png',
|
|
24
|
-
}),
|
|
25
|
-
});
|
|
26
|
-
await page.waitForChanges();
|
|
27
|
-
expect(page.root).toEqualHtml(`
|
|
28
|
-
<pos-picture>
|
|
29
|
-
<mock:shadow-root><pos-image src="https://resource.test/picture.png" alt="a picture"/></mock:shadow-root>
|
|
30
|
-
</pos-picture>
|
|
31
|
-
`);
|
|
32
|
-
});
|
|
33
|
-
it('renders nothing when resource has no picture', async () => {
|
|
34
|
-
const page = await newSpecPage({
|
|
35
|
-
components: [PosPicture],
|
|
36
|
-
html: `<pos-picture />`,
|
|
37
|
-
});
|
|
38
|
-
await page.rootInstance.receiveResource({
|
|
39
|
-
picture: () => null,
|
|
40
|
-
});
|
|
41
|
-
await page.waitForChanges();
|
|
42
|
-
expect(page.root).toEqualHtml(`
|
|
43
|
-
<pos-picture>
|
|
44
|
-
<mock:shadow-root></mock:shadow-root>
|
|
45
|
-
</pos-picture>
|
|
46
|
-
`);
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
//# sourceMappingURL=pos-picture.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pos-picture.spec.js","sourceRoot":"","sources":["../../../../src/components/pos-picture/pos-picture.spec.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,QAAQ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CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { newSpecPage } from '@stencil/core/testing';\nimport { PosPicture } from './pos-picture';\n\ndescribe('pos-picture', () => {\n it('is empty initially', async () => {\n const page = await newSpecPage({\n components: [PosPicture],\n html: `<pos-picture />`,\n });\n expect(page.root).toEqualHtml(`\n <pos-picture>\n <mock:shadow-root></mock:shadow-root>\n </pos-picture>\n `);\n });\n\n it('renders pos-image depicting resource', async () => {\n const page = await newSpecPage({\n components: [PosPicture],\n html: `<pos-picture />`,\n });\n await page.rootInstance.receiveResource({\n label: () => 'a picture',\n picture: () => ({\n url: 'https://resource.test/picture.png',\n }),\n });\n await page.waitForChanges();\n expect(page.root).toEqualHtml(`\n <pos-picture>\n <mock:shadow-root><pos-image src=\"https://resource.test/picture.png\" alt=\"a picture\"/></mock:shadow-root>\n </pos-picture>\n `);\n });\n\n it('renders nothing when resource has no picture', async () => {\n const page = await newSpecPage({\n components: [PosPicture],\n html: `<pos-picture />`,\n });\n await page.rootInstance.receiveResource({\n picture: () => null,\n });\n await page.waitForChanges();\n expect(page.root).toEqualHtml(`\n <pos-picture>\n <mock:shadow-root></mock:shadow-root>\n </pos-picture>\n `);\n });\n});\n"]}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { newSpecPage } from "@stencil/core/testing";
|
|
2
|
-
import { getByText } from "@testing-library/dom";
|
|
3
|
-
import { PosRelations } from "./pos-relations";
|
|
4
|
-
describe('pos-relations', () => {
|
|
5
|
-
it('are empty initially', async () => {
|
|
6
|
-
const page = await newSpecPage({
|
|
7
|
-
components: [PosRelations],
|
|
8
|
-
html: `<pos-relations />`,
|
|
9
|
-
});
|
|
10
|
-
expect(page.root).toEqualHtml(`
|
|
11
|
-
<pos-relations>
|
|
12
|
-
<mock:shadow-root></mock:shadow-root>
|
|
13
|
-
</pos-relations>
|
|
14
|
-
`);
|
|
15
|
-
});
|
|
16
|
-
it('renders single predicate and rich link to resource', async () => {
|
|
17
|
-
const page = await newSpecPage({
|
|
18
|
-
components: [PosRelations],
|
|
19
|
-
html: `<pos-relations />`,
|
|
20
|
-
});
|
|
21
|
-
await page.rootInstance.receiveResource({
|
|
22
|
-
relations: () => [
|
|
23
|
-
{
|
|
24
|
-
predicate: 'http://schema.org/url',
|
|
25
|
-
uris: ['https://person.test/alice'],
|
|
26
|
-
},
|
|
27
|
-
],
|
|
28
|
-
});
|
|
29
|
-
await page.waitForChanges();
|
|
30
|
-
const el = page.root.shadowRoot;
|
|
31
|
-
expect(getByText(el, 'http://schema.org/url')).toBeDefined();
|
|
32
|
-
const linkToAlice = page.root.shadowRoot.querySelector('pos-rich-link[uri="https://person.test/alice"]');
|
|
33
|
-
expect(linkToAlice).not.toBeNull();
|
|
34
|
-
});
|
|
35
|
-
it('renders multiple predicates and rich links to resource', async () => {
|
|
36
|
-
const page = await newSpecPage({
|
|
37
|
-
components: [PosRelations],
|
|
38
|
-
html: `<pos-relations />`,
|
|
39
|
-
});
|
|
40
|
-
await page.rootInstance.receiveResource({
|
|
41
|
-
relations: () => [
|
|
42
|
-
{
|
|
43
|
-
predicate: 'http://schema.org/url',
|
|
44
|
-
uris: ['https://person.test/alice', 'https://person.test/bernadette'],
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
predicate: 'https://www.w3.org/ns/activitystreams#attachment',
|
|
48
|
-
uris: ['https://resource.test/attachment'],
|
|
49
|
-
},
|
|
50
|
-
],
|
|
51
|
-
});
|
|
52
|
-
await page.waitForChanges();
|
|
53
|
-
const el = page.root.shadowRoot;
|
|
54
|
-
expect(getByText(el, 'http://schema.org/url')).toBeDefined();
|
|
55
|
-
const linkToAlice = page.root.shadowRoot.querySelector('pos-rich-link[uri="https://person.test/alice"]');
|
|
56
|
-
expect(linkToAlice).not.toBeNull();
|
|
57
|
-
const linkToBernadette = page.root.shadowRoot.querySelector('pos-rich-link[uri="https://person.test/bernadette"]');
|
|
58
|
-
expect(linkToBernadette).not.toBeNull();
|
|
59
|
-
expect(getByText(el, 'https://www.w3.org/ns/activitystreams#attachment')).toBeDefined();
|
|
60
|
-
const linkToAttachment = page.root.shadowRoot.querySelector('pos-rich-link[uri="https://resource.test/attachment"]');
|
|
61
|
-
expect(linkToAttachment).not.toBeNull();
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
//# sourceMappingURL=pos-relations.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pos-relations.spec.js","sourceRoot":"","sources":["../../../../src/components/pos-relations/pos-relations.spec.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;EAC7B,EAAE,CAAC,qBAAqB,EAAE,KAAK,IAAI,EAAE;IACnC,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC;MAC7B,UAAU,EAAE,CAAC,YAAY,CAAC;MAC1B,IAAI,EAAE,mBAAmB;KAC1B,CAAC,CAAC;IACH,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC;;;;GAI/B,CAAC,CAAC;EACH,CAAC,CAAC,CAAC;EAEH,EAAE,CAAC,oDAAoD,EAAE,KAAK,IAAI,EAAE;IAClE,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC;MAC7B,UAAU,EAAE,CAAC,YAAY,CAAC;MAC1B,IAAI,EAAE,mBAAmB;KAC1B,CAAC,CAAC;IACH,MAAM,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC;MACtC,SAAS,EAAE,GAAG,EAAE,CAAC;QACf;UACE,SAAS,EAAE,uBAAuB;UAClC,IAAI,EAAE,CAAC,2BAA2B,CAAC;SACpC;OACF;KACF,CAAC,CAAC;IACH,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;IAE5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H,MAAM,CAAC,gBAAgB,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;IAExC,MAAM,CAAC,SAAS,CAAC,EAAE,EAAE,kDAAkD,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IACxF,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,uDAAuD,CAAC,CAAC;IACrH,MAAM,CAAC,gBAAgB,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;EAC1C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { newSpecPage } from '@stencil/core/testing';\n\nimport { getByText } from '@testing-library/dom';\n\nimport { PosRelations } from './pos-relations';\n\ndescribe('pos-relations', () => {\n it('are empty initially', async () => {\n const page = await newSpecPage({\n components: [PosRelations],\n html: `<pos-relations />`,\n });\n expect(page.root).toEqualHtml(`\n <pos-relations>\n <mock:shadow-root></mock:shadow-root>\n </pos-relations>\n `);\n });\n\n it('renders single predicate and rich link to resource', async () => {\n const page = await newSpecPage({\n components: [PosRelations],\n html: `<pos-relations />`,\n });\n await page.rootInstance.receiveResource({\n relations: () => [\n {\n predicate: 'http://schema.org/url',\n uris: ['https://person.test/alice'],\n },\n ],\n });\n await page.waitForChanges();\n\n const el: HTMLElement = page.root.shadowRoot as unknown as HTMLElement;\n\n expect(getByText(el, 'http://schema.org/url')).toBeDefined();\n const linkToAlice = page.root.shadowRoot.querySelector('pos-rich-link[uri=\"https://person.test/alice\"]');\n expect(linkToAlice).not.toBeNull();\n });\n\n it('renders multiple predicates and rich links to resource', async () => {\n const page = await newSpecPage({\n components: [PosRelations],\n html: `<pos-relations />`,\n });\n await page.rootInstance.receiveResource({\n relations: () => [\n {\n predicate: 'http://schema.org/url',\n uris: ['https://person.test/alice', 'https://person.test/bernadette'],\n },\n {\n predicate: 'https://www.w3.org/ns/activitystreams#attachment',\n uris: ['https://resource.test/attachment'],\n },\n ],\n });\n await page.waitForChanges();\n\n const el: HTMLElement = page.root.shadowRoot as unknown as HTMLElement;\n\n expect(getByText(el, 'http://schema.org/url')).toBeDefined();\n const linkToAlice = page.root.shadowRoot.querySelector('pos-rich-link[uri=\"https://person.test/alice\"]');\n expect(linkToAlice).not.toBeNull();\n const linkToBernadette = page.root.shadowRoot.querySelector('pos-rich-link[uri=\"https://person.test/bernadette\"]');\n expect(linkToBernadette).not.toBeNull();\n\n expect(getByText(el, 'https://www.w3.org/ns/activitystreams#attachment')).toBeDefined();\n const linkToAttachment = page.root.shadowRoot.querySelector('pos-rich-link[uri=\"https://resource.test/attachment\"]');\n expect(linkToAttachment).not.toBeNull();\n });\n});\n"]}
|