@3t-transform/threeteeui 0.1.7 → 0.1.8
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/{index-451f61dd.js → index-8ba406f6.js} +91 -3
- package/dist/cjs/loader.cjs.js +3 -18
- package/dist/cjs/tttx-button.cjs.entry.js +2 -2
- package/dist/cjs/tttx-form.cjs.entry.js +1 -1
- package/dist/cjs/tttx-icon.cjs.entry.js +1 -1
- package/dist/cjs/tttx-keyvalue-block.cjs.entry.js +1 -1
- package/dist/cjs/tttx-list.cjs.entry.js +4 -34
- package/dist/cjs/tttx-loading-spinner.cjs.entry.js +1 -1
- package/dist/cjs/tttx-standalone-input.cjs.entry.js +1 -1
- package/dist/cjs/tttx-toolbar.cjs.entry.js +1 -1
- package/dist/cjs/tttx.cjs.js +8 -116
- package/dist/collection/collection-manifest.json +2 -2
- package/dist/collection/components/atoms/tttx-button/tttx-button.css +8 -0
- package/dist/collection/components/molecules/tttx-standalone-input/tttx-standalone-input.stories.js +13 -0
- package/dist/collection/components/molecules/tttx-toolbar/tttx-toolbar.stories.js +1 -1
- package/dist/components/index.d.ts +9 -0
- package/dist/components/index.js +1 -5
- package/dist/components/tttx-button.js +1 -1
- package/dist/components/tttx-list.js +3 -33
- package/dist/esm/{index-0350f122.js → index-5f9b72ff.js} +91 -4
- package/dist/esm/loader.js +3 -18
- package/dist/esm/polyfills/css-shim.js +1 -1
- package/dist/esm/tttx-button.entry.js +2 -2
- package/dist/esm/tttx-form.entry.js +1 -1
- package/dist/esm/tttx-icon.entry.js +1 -1
- package/dist/esm/tttx-keyvalue-block.entry.js +1 -1
- package/dist/esm/tttx-list.entry.js +4 -34
- package/dist/esm/tttx-loading-spinner.entry.js +1 -1
- package/dist/esm/tttx-standalone-input.entry.js +1 -1
- package/dist/esm/tttx-toolbar.entry.js +1 -1
- package/dist/esm/tttx.js +5 -116
- package/dist/tttx/index.esm.js +0 -1
- package/dist/tttx/{p-0a85dda4.entry.js → p-0342cc46.entry.js} +1 -1
- package/dist/tttx/p-1290dcd7.entry.js +3 -0
- package/dist/tttx/{p-a0179cb1.entry.js → p-1b394414.entry.js} +1 -1
- package/dist/tttx/{p-5cae1beb.entry.js → p-405219b2.entry.js} +1 -1
- package/dist/tttx/{p-4f3958fa.entry.js → p-435c62b3.entry.js} +1 -1
- package/dist/tttx/{p-1b015a9d.entry.js → p-4ecc9e8b.entry.js} +1 -1
- package/dist/tttx/{p-cc6644c9.entry.js → p-9cff9c64.entry.js} +1 -1
- package/dist/tttx/{p-92465671.entry.js → p-adf35f58.entry.js} +1 -1
- package/dist/tttx/p-c4b803fc.js +2 -0
- package/dist/tttx/tttx.esm.js +1 -129
- package/dist/types/components/molecules/tttx-standalone-input/tttx-standalone-input.d.ts +6 -6
- package/dist/types/components/molecules/tttx-standalone-input/tttx-standalone-input.stories.d.ts +1 -0
- package/dist/types/stencil-public-runtime.d.ts +59 -3
- package/loader/index.d.ts +9 -0
- package/package.json +1 -1
- package/dist/cjs/app-globals-3a1e7e63.js +0 -5
- package/dist/cjs/css-shim-211819bc.js +0 -6
- package/dist/cjs/dom-9deb26c8.js +0 -75
- package/dist/cjs/index-11cfdabe.js +0 -3297
- package/dist/cjs/shadow-css-bf3843d2.js +0 -389
- package/dist/collection/components/atoms/tttx-button/test/tttx-button.e2e.js +0 -9
- package/dist/collection/components/atoms/tttx-button/test/tttx-button.spec.js +0 -83
- package/dist/collection/components/atoms/tttx-icon/test/tttx-icon.e2e.js +0 -9
- package/dist/collection/components/atoms/tttx-icon/test/tttx-icon.spec.js +0 -16
- package/dist/collection/components/atoms/tttx-keyvalue-block/test/tttx-keyvalue-block.spec.js +0 -216
- package/dist/collection/components/atoms/tttx-loading-spinner/Test/tttx-loading-spinner.spec.js +0 -64
- package/dist/collection/components/molecules/tttx-form/lib/setErrorState.spec.js +0 -38
- package/dist/collection/components/molecules/tttx-form/lib/validityCheck.spec.js +0 -214
- package/dist/collection/components/molecules/tttx-form/test/tttx-form.e2e.js +0 -9
- package/dist/collection/components/molecules/tttx-form/test/tttx-form.spec.js +0 -232
- package/dist/collection/components/molecules/tttx-list/test/ttttx-list.spec.e2e.js +0 -26
- package/dist/collection/components/molecules/tttx-list/test/tttx-list.spec.js +0 -183
- package/dist/collection/components/molecules/tttx-standalone-input/test/tttx-standalone-input.e2e.js +0 -9
- package/dist/collection/components/molecules/tttx-standalone-input/test/tttx-standalone-input.spec.js +0 -219
- package/dist/collection/components/molecules/tttx-toolbar/test/tttx-toolbar.test.js +0 -0
- package/dist/collection/shared/test/domsanitiser.options.spec.js +0 -23
- package/dist/esm/app-globals-0f993ce5.js +0 -3
- package/dist/esm/css-shim-9d54a2f2.js +0 -4
- package/dist/esm/dom-6be6f662.js +0 -73
- package/dist/esm/index-dbe25028.js +0 -3262
- package/dist/esm/shadow-css-ed4599f8.js +0 -387
- package/dist/tttx/app-globals-0f993ce5.js +0 -3
- package/dist/tttx/css-shim-9d54a2f2.js +0 -4
- package/dist/tttx/dom-6be6f662.js +0 -73
- package/dist/tttx/index-dbe25028.js +0 -3262
- package/dist/tttx/p-62869344.js +0 -2
- package/dist/tttx/p-cd1565e0.entry.js +0 -3
- package/dist/tttx/shadow-css-ed4599f8.js +0 -387
- package/dist/tttx/tttx-button.entry.js +0 -30
- package/dist/tttx/tttx-form.entry.js +0 -373
- package/dist/tttx/tttx-icon.entry.js +0 -17
- package/dist/tttx/tttx-keyvalue-block.entry.js +0 -63
- package/dist/tttx/tttx-list.entry.js +0 -1730
- package/dist/tttx/tttx-loading-spinner.entry.js +0 -22
- package/dist/tttx/tttx-standalone-input.entry.js +0 -66
- package/dist/tttx/tttx-toolbar.entry.js +0 -16
- package/dist/types/components/atoms/tttx-button/test/tttx-button.e2e.d.ts +0 -1
- package/dist/types/components/atoms/tttx-button/test/tttx-button.spec.d.ts +0 -1
- package/dist/types/components/atoms/tttx-icon/test/tttx-icon.e2e.d.ts +0 -1
- package/dist/types/components/atoms/tttx-icon/test/tttx-icon.spec.d.ts +0 -1
- package/dist/types/components/atoms/tttx-keyvalue-block/test/tttx-keyvalue-block.spec.d.ts +0 -1
- package/dist/types/components/atoms/tttx-loading-spinner/Test/tttx-loading-spinner.spec.d.ts +0 -1
- package/dist/types/components/molecules/tttx-form/lib/setErrorState.spec.d.ts +0 -1
- package/dist/types/components/molecules/tttx-form/lib/validityCheck.spec.d.ts +0 -1
- package/dist/types/components/molecules/tttx-form/test/tttx-form.e2e.d.ts +0 -1
- package/dist/types/components/molecules/tttx-form/test/tttx-form.spec.d.ts +0 -1
- package/dist/types/components/molecules/tttx-list/test/ttttx-list.spec.e2e.d.ts +0 -1
- package/dist/types/components/molecules/tttx-list/test/tttx-list.spec.d.ts +0 -1
- package/dist/types/components/molecules/tttx-standalone-input/test/tttx-standalone-input.e2e.d.ts +0 -1
- package/dist/types/components/molecules/tttx-standalone-input/test/tttx-standalone-input.spec.d.ts +0 -1
- package/dist/types/components/molecules/tttx-toolbar/test/tttx-toolbar.test.d.ts +0 -0
- package/dist/types/shared/test/domsanitiser.options.spec.d.ts +0 -1
|
@@ -1,232 +0,0 @@
|
|
|
1
|
-
import { h } from '@stencil/core';
|
|
2
|
-
import { newSpecPage } from '@stencil/core/testing';
|
|
3
|
-
import { TttxForm } from '../tttx-form';
|
|
4
|
-
describe('tttx-form', () => {
|
|
5
|
-
it('renders', async () => {
|
|
6
|
-
const page = await newSpecPage({
|
|
7
|
-
components: [TttxForm],
|
|
8
|
-
html: '<tttx-form></tttx-form>',
|
|
9
|
-
});
|
|
10
|
-
expect(page.root).toEqualHtml(`
|
|
11
|
-
<tttx-form>
|
|
12
|
-
<mock:shadow-root>
|
|
13
|
-
<form>
|
|
14
|
-
<fieldset></fieldset>
|
|
15
|
-
</form>
|
|
16
|
-
</mock:shadow-root>
|
|
17
|
-
</tttx-form>
|
|
18
|
-
`);
|
|
19
|
-
});
|
|
20
|
-
it('renders a single form item', async () => {
|
|
21
|
-
const singleFormItemSchema = {
|
|
22
|
-
properties: {
|
|
23
|
-
input: {
|
|
24
|
-
type: 'string',
|
|
25
|
-
format: 'string',
|
|
26
|
-
form: {
|
|
27
|
-
type: 'text',
|
|
28
|
-
label: 'Input Field',
|
|
29
|
-
validation: {
|
|
30
|
-
required: {
|
|
31
|
-
message: 'Please enter something'
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
const page = await newSpecPage({
|
|
39
|
-
components: [TttxForm],
|
|
40
|
-
html: `<tttx-form formschema='${JSON.stringify(singleFormItemSchema)}'></tttx-form>`,
|
|
41
|
-
});
|
|
42
|
-
expect(page.root).toEqualHtml(`
|
|
43
|
-
<tttx-form formschema='${JSON.stringify(singleFormItemSchema)}'>
|
|
44
|
-
<mock:shadow-root>
|
|
45
|
-
<form>
|
|
46
|
-
<fieldset>
|
|
47
|
-
<label class="inputBlock">
|
|
48
|
-
Input Field
|
|
49
|
-
<input autocomplete="off" data-required="Please enter something" name="input" placeholder="" required="" type="text" />
|
|
50
|
-
<div class="errorBubble"></div>
|
|
51
|
-
</label>
|
|
52
|
-
<input class="button primary-blue" type="submit" value="Save">
|
|
53
|
-
</fieldset>
|
|
54
|
-
</form>
|
|
55
|
-
</mock:shadow-root>
|
|
56
|
-
</tttx-form>
|
|
57
|
-
`);
|
|
58
|
-
});
|
|
59
|
-
it('renders without validation', async () => {
|
|
60
|
-
const singleFormItemSchema = {
|
|
61
|
-
properties: {
|
|
62
|
-
input: {
|
|
63
|
-
type: 'string',
|
|
64
|
-
format: 'string',
|
|
65
|
-
form: {
|
|
66
|
-
type: 'text',
|
|
67
|
-
label: 'Input Field'
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
const page = await newSpecPage({
|
|
73
|
-
components: [TttxForm],
|
|
74
|
-
html: `<tttx-form formschema='${JSON.stringify(singleFormItemSchema)}'></tttx-form>`,
|
|
75
|
-
});
|
|
76
|
-
expect(page.root).toEqualHtml(`
|
|
77
|
-
<tttx-form formschema='${JSON.stringify(singleFormItemSchema)}'>
|
|
78
|
-
<mock:shadow-root>
|
|
79
|
-
<form>
|
|
80
|
-
<fieldset>
|
|
81
|
-
<label class="inputBlock">
|
|
82
|
-
Input Field
|
|
83
|
-
<span class="optional">
|
|
84
|
-
(optional)
|
|
85
|
-
</span>
|
|
86
|
-
<input autocomplete="off" name="input" placeholder="" type="text" />
|
|
87
|
-
<div class="errorBubble"></div>
|
|
88
|
-
</label>
|
|
89
|
-
<input class="button primary-blue" type="submit" value="Save">
|
|
90
|
-
</fieldset>
|
|
91
|
-
</form>
|
|
92
|
-
</mock:shadow-root>
|
|
93
|
-
</tttx-form>
|
|
94
|
-
`);
|
|
95
|
-
});
|
|
96
|
-
it('renders a complex form', async () => {
|
|
97
|
-
const formSchema = {
|
|
98
|
-
properties: {
|
|
99
|
-
title: {
|
|
100
|
-
type: 'string',
|
|
101
|
-
format: 'string',
|
|
102
|
-
form: {
|
|
103
|
-
type: 'text',
|
|
104
|
-
placeholder: 'Mr, Mrs, Dr, Hon Rev',
|
|
105
|
-
label: 'Title',
|
|
106
|
-
},
|
|
107
|
-
},
|
|
108
|
-
forename: {
|
|
109
|
-
type: 'string',
|
|
110
|
-
format: 'string',
|
|
111
|
-
form: {
|
|
112
|
-
type: 'text',
|
|
113
|
-
placeholder: 'John',
|
|
114
|
-
label: 'Forename',
|
|
115
|
-
validation: {
|
|
116
|
-
required: {
|
|
117
|
-
message: 'Please enter your forename',
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
},
|
|
121
|
-
},
|
|
122
|
-
surname: {
|
|
123
|
-
type: 'string',
|
|
124
|
-
format: 'string',
|
|
125
|
-
form: {
|
|
126
|
-
type: 'text',
|
|
127
|
-
placeholder: 'Doe',
|
|
128
|
-
label: 'Surname',
|
|
129
|
-
validation: {
|
|
130
|
-
required: {
|
|
131
|
-
message: 'Please enter your surname',
|
|
132
|
-
},
|
|
133
|
-
},
|
|
134
|
-
},
|
|
135
|
-
},
|
|
136
|
-
postcode: {
|
|
137
|
-
type: 'string',
|
|
138
|
-
format: 'string',
|
|
139
|
-
form: {
|
|
140
|
-
type: 'text',
|
|
141
|
-
placeholder: 'AB10',
|
|
142
|
-
label: 'Start of postcode',
|
|
143
|
-
validation: {
|
|
144
|
-
required: {
|
|
145
|
-
message: 'Please enter the beginning of your postcode',
|
|
146
|
-
},
|
|
147
|
-
pattern: {
|
|
148
|
-
pattern: '^([A-Za-z][0-9])$|^([A-Za-z][0-9]{2})$|^([A-Za-z]{2}[0-9])$|^([A-Za-z]{2}[0-9]{2})$|^([A-Za-z][0-9][A-Za-z])$|^([A-Za-z]{2}[0-9][A-Za-z])$|^(GIR|BF|BX|XX)$',
|
|
149
|
-
message: 'Please enter the first half of your postcode. EG: ZZ99',
|
|
150
|
-
},
|
|
151
|
-
maxlength: 4,
|
|
152
|
-
},
|
|
153
|
-
},
|
|
154
|
-
},
|
|
155
|
-
age: {
|
|
156
|
-
type: 'number',
|
|
157
|
-
format: 'number',
|
|
158
|
-
form: {
|
|
159
|
-
type: 'number',
|
|
160
|
-
placeholder: '',
|
|
161
|
-
label: 'Age',
|
|
162
|
-
validation: {
|
|
163
|
-
required: {
|
|
164
|
-
message: 'Please enter your age',
|
|
165
|
-
},
|
|
166
|
-
badInput: {
|
|
167
|
-
message: 'Please enter a number',
|
|
168
|
-
},
|
|
169
|
-
},
|
|
170
|
-
},
|
|
171
|
-
},
|
|
172
|
-
dob: {
|
|
173
|
-
type: 'string',
|
|
174
|
-
format: 'date-time',
|
|
175
|
-
form: {
|
|
176
|
-
type: 'date',
|
|
177
|
-
placeholder: '',
|
|
178
|
-
label: 'Date of birth',
|
|
179
|
-
validation: {
|
|
180
|
-
required: {
|
|
181
|
-
message: 'Please enter your date of birth',
|
|
182
|
-
},
|
|
183
|
-
minmax: {
|
|
184
|
-
min: '1900-01-01',
|
|
185
|
-
max: '2100-12-31',
|
|
186
|
-
message: 'Please enter a date between 1900 and 2100',
|
|
187
|
-
},
|
|
188
|
-
},
|
|
189
|
-
},
|
|
190
|
-
},
|
|
191
|
-
},
|
|
192
|
-
};
|
|
193
|
-
const page = await newSpecPage({
|
|
194
|
-
components: [TttxForm],
|
|
195
|
-
template: () => (h("tttx-form", { formschema: formSchema })),
|
|
196
|
-
});
|
|
197
|
-
expect(page.root).toEqualHtml(`
|
|
198
|
-
<tttx-form>
|
|
199
|
-
<mock:shadow-root>
|
|
200
|
-
<form>
|
|
201
|
-
<fieldset>
|
|
202
|
-
<label class="inputBlock">Title<span class="optional"> (optional)</span>
|
|
203
|
-
<input autocomplete="off" name="title" placeholder="Mr, Mrs, Dr, Hon Rev" type="text" />
|
|
204
|
-
<div class="errorBubble"></div>
|
|
205
|
-
</label>
|
|
206
|
-
<label class="inputBlock">Forename
|
|
207
|
-
<input autocomplete="off" data-required="Please enter your forename" name="forename" placeholder="John" required="" type="text"/>
|
|
208
|
-
<div class="errorBubble"></div>
|
|
209
|
-
</label>
|
|
210
|
-
<label class="inputBlock">Surname
|
|
211
|
-
<input autocomplete="off" data-required="Please enter your surname" name="surname" placeholder="Doe" required="" type="text">
|
|
212
|
-
<div class="errorBubble"></div>
|
|
213
|
-
</label>
|
|
214
|
-
<label class="inputBlock">Start of postcode
|
|
215
|
-
<input autocomplete="off" data-pattern="Please enter the first half of your postcode. EG: ZZ99" data-required="Please enter the beginning of your postcode" maxlength="4" name="postcode" pattern="^([A-Za-z][0-9])$|^([A-Za-z][0-9]{2})$|^([A-Za-z]{2}[0-9])$|^([A-Za-z]{2}[0-9]{2})$|^([A-Za-z][0-9][A-Za-z])$|^([A-Za-z]{2}[0-9][A-Za-z])$|^(GIR|BF|BX|XX)$" placeholder="AB10" required="" type="text">
|
|
216
|
-
<div class="errorBubble"></div>
|
|
217
|
-
</label>
|
|
218
|
-
<label class="inputBlock">Age
|
|
219
|
-
<input autocomplete="off" data-badinput="Please enter a number" data-required="Please enter your age" name="age" placeholder="" required="" type="number">
|
|
220
|
-
<div class="errorBubble"></div>
|
|
221
|
-
</label>
|
|
222
|
-
<label class="inputBlock">Date of birth
|
|
223
|
-
<input autocomplete="off" data-range="Please enter a date between 1900 and 2100" data-required="Please enter your date of birth" max="2100-12-31" min="1900-01-01" name="dob" placeholder="" required="" type="date">
|
|
224
|
-
<div class="errorBubble"></div>
|
|
225
|
-
</label>
|
|
226
|
-
<input type="submit" class="button primary-blue" value="Save"></fieldset>
|
|
227
|
-
</form>
|
|
228
|
-
</mock:shadow-root>
|
|
229
|
-
</tttx-form>
|
|
230
|
-
`);
|
|
231
|
-
});
|
|
232
|
-
});
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { newE2EPage } from '@stencil/core/testing';
|
|
2
|
-
describe('tttx-list', () => {
|
|
3
|
-
it('sanitises the html of the element property', async () => {
|
|
4
|
-
const page = await newE2EPage();
|
|
5
|
-
await page.setContent('<tttx-list></tttx-list>');
|
|
6
|
-
await page.$eval('tttx-list', (elm) => {
|
|
7
|
-
elm.data = [{ element: '<span><tttx-icon icon="egg" color="blue"></tttx-icon></span>Test<script>alert(4)</script>' }];
|
|
8
|
-
});
|
|
9
|
-
await page.waitForChanges();
|
|
10
|
-
const element = await page.find('tttx-list');
|
|
11
|
-
expect(element).toEqualHtml(`
|
|
12
|
-
<tttx-list class="hydrated">
|
|
13
|
-
<mock:shadow-root>
|
|
14
|
-
<ul class="list">
|
|
15
|
-
<li class="item">
|
|
16
|
-
<span class="item-content">
|
|
17
|
-
<span><tttx-icon class="hydrated" icon="egg" color="blue"></tttx-icon></span>
|
|
18
|
-
Test
|
|
19
|
-
</span>
|
|
20
|
-
</li>
|
|
21
|
-
</ul>
|
|
22
|
-
</mock:shadow-root>
|
|
23
|
-
</tttx-list>
|
|
24
|
-
`);
|
|
25
|
-
});
|
|
26
|
-
});
|
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
import { newSpecPage } from '@stencil/core/testing';
|
|
2
|
-
import { TttxList } from '../tttx-list';
|
|
3
|
-
describe('tttx-list', () => {
|
|
4
|
-
it('renders data using JS objects (with icon, clickable)', async () => {
|
|
5
|
-
const page = await newSpecPage({
|
|
6
|
-
components: [TttxList],
|
|
7
|
-
html: '<tttx-list></tttx-list>',
|
|
8
|
-
});
|
|
9
|
-
page.rootInstance.data = [{ icon: 'info', element: '<span><tttx-icon icon="egg" color="blue" /></span> Test', clickable: true }];
|
|
10
|
-
await page.waitForChanges();
|
|
11
|
-
expect(page.root).toEqualHtml(`
|
|
12
|
-
<tttx-list>
|
|
13
|
-
<mock:shadow-root>
|
|
14
|
-
<ul class="list">
|
|
15
|
-
<li class="item clickable">
|
|
16
|
-
<span class="item-content">
|
|
17
|
-
<span><tttx-icon icon="egg" color="blue"></tttx-icon></span>
|
|
18
|
-
Test
|
|
19
|
-
</span>
|
|
20
|
-
<tttx-icon class="align-right" icon="info"></tttx-icon>
|
|
21
|
-
</li>
|
|
22
|
-
</ul>
|
|
23
|
-
</mock:shadow-root>
|
|
24
|
-
</tttx-list>
|
|
25
|
-
`);
|
|
26
|
-
});
|
|
27
|
-
it('renders data using JS objects (with icon, clickable:false)', async () => {
|
|
28
|
-
const page = await newSpecPage({
|
|
29
|
-
components: [TttxList],
|
|
30
|
-
html: '<tttx-list></tttx-list>',
|
|
31
|
-
});
|
|
32
|
-
page.rootInstance.data = [{ icon: 'info', element: '<span><tttx-icon icon="egg" color="blue" /></span> Test' }];
|
|
33
|
-
await page.waitForChanges();
|
|
34
|
-
expect(page.root).toEqualHtml(`
|
|
35
|
-
<tttx-list>
|
|
36
|
-
<mock:shadow-root>
|
|
37
|
-
<ul class="list">
|
|
38
|
-
<li class="item">
|
|
39
|
-
<span class="item-content">
|
|
40
|
-
<span><tttx-icon icon="egg" color="blue"></tttx-icon></span>
|
|
41
|
-
Test
|
|
42
|
-
</span>
|
|
43
|
-
<tttx-icon class="align-right" icon="info"></tttx-icon>
|
|
44
|
-
</li>
|
|
45
|
-
</ul>
|
|
46
|
-
</mock:shadow-root>
|
|
47
|
-
</tttx-list>
|
|
48
|
-
`);
|
|
49
|
-
});
|
|
50
|
-
it('renders data using JS objects (without icon, clickable)', async () => {
|
|
51
|
-
const page = await newSpecPage({
|
|
52
|
-
components: [TttxList],
|
|
53
|
-
html: '<tttx-list></tttx-list>',
|
|
54
|
-
});
|
|
55
|
-
page.rootInstance.data = [{ element: '<span><tttx-icon icon="egg" color="blue" /></span> Test', clickable: true }];
|
|
56
|
-
await page.waitForChanges();
|
|
57
|
-
expect(page.root).toEqualHtml(`
|
|
58
|
-
<tttx-list>
|
|
59
|
-
<mock:shadow-root>
|
|
60
|
-
<ul class="list">
|
|
61
|
-
<li class="item clickable">
|
|
62
|
-
<span class="item-content">
|
|
63
|
-
<span><tttx-icon icon="egg" color="blue"></tttx-icon></span>
|
|
64
|
-
Test
|
|
65
|
-
</span>
|
|
66
|
-
</li>
|
|
67
|
-
</ul>
|
|
68
|
-
</mock:shadow-root>
|
|
69
|
-
</tttx-list>
|
|
70
|
-
`);
|
|
71
|
-
});
|
|
72
|
-
it('renders data using JS objects (without icon, clickable:false)', async () => {
|
|
73
|
-
const page = await newSpecPage({
|
|
74
|
-
components: [TttxList],
|
|
75
|
-
html: '<tttx-list></tttx-list>',
|
|
76
|
-
});
|
|
77
|
-
page.rootInstance.data = [{ element: '<span><tttx-icon icon="egg" color="blue" /></span> Test' }];
|
|
78
|
-
await page.waitForChanges();
|
|
79
|
-
expect(page.root).toEqualHtml(`
|
|
80
|
-
<tttx-list>
|
|
81
|
-
<mock:shadow-root>
|
|
82
|
-
<ul class="list">
|
|
83
|
-
<li class="item">
|
|
84
|
-
<span class="item-content">
|
|
85
|
-
<span><tttx-icon icon="egg" color="blue"></tttx-icon></span>
|
|
86
|
-
Test
|
|
87
|
-
</span>
|
|
88
|
-
</li>
|
|
89
|
-
</ul>
|
|
90
|
-
</mock:shadow-root>
|
|
91
|
-
</tttx-list>
|
|
92
|
-
`);
|
|
93
|
-
});
|
|
94
|
-
it('renders data using JSON', async () => {
|
|
95
|
-
const data = '[{ "icon": "info", "element": "<span><tttx-icon icon=\\"egg\\" color=\\"blue\\" /></span> Test", "clickable": true }]';
|
|
96
|
-
const page = await newSpecPage({
|
|
97
|
-
components: [TttxList],
|
|
98
|
-
html: `<tttx-list data='${data}'></tttx-list>`,
|
|
99
|
-
});
|
|
100
|
-
await page.waitForChanges();
|
|
101
|
-
expect(page.root).toEqualHtml(`
|
|
102
|
-
<tttx-list data="[{ "icon": "info", "element": "<span><tttx-icon icon=\\"egg\\" color=\\"blue\\" /></span> Test", "clickable": true }]">
|
|
103
|
-
<mock:shadow-root>
|
|
104
|
-
<ul class="list">
|
|
105
|
-
<li class="item clickable">
|
|
106
|
-
<span class="item-content">
|
|
107
|
-
<span><tttx-icon icon="egg" color="blue"></tttx-icon></span>
|
|
108
|
-
Test
|
|
109
|
-
</span>
|
|
110
|
-
<tttx-icon class="align-right" icon="info"></tttx-icon>
|
|
111
|
-
</li>
|
|
112
|
-
</ul>
|
|
113
|
-
</mock:shadow-root>
|
|
114
|
-
</tttx-list>
|
|
115
|
-
`);
|
|
116
|
-
});
|
|
117
|
-
it('renders nothing when there is no data', async () => {
|
|
118
|
-
const page = await newSpecPage({
|
|
119
|
-
components: [TttxList],
|
|
120
|
-
html: '<tttx-list></tttx-list>',
|
|
121
|
-
});
|
|
122
|
-
page.rootInstance.data = [];
|
|
123
|
-
await page.waitForChanges();
|
|
124
|
-
expect(page.root).toEqualHtml(`
|
|
125
|
-
<tttx-list>
|
|
126
|
-
<mock:shadow-root>
|
|
127
|
-
<ul class="list">
|
|
128
|
-
</ul>
|
|
129
|
-
</mock:shadow-root>
|
|
130
|
-
</tttx-list>
|
|
131
|
-
`);
|
|
132
|
-
});
|
|
133
|
-
it('emits listRowClick event when a clickable row is clicked', async () => {
|
|
134
|
-
const page = await newSpecPage({
|
|
135
|
-
components: [TttxList],
|
|
136
|
-
html: '<tttx-list name="test-list"></tttx-list>',
|
|
137
|
-
});
|
|
138
|
-
const eventSpy = jest.fn();
|
|
139
|
-
page.doc.addEventListener('listRowClick', eventSpy);
|
|
140
|
-
page.rootInstance.data = [
|
|
141
|
-
{ element: '<div>Item 1</div>', clickable: true, rowData: 'Item 1' },
|
|
142
|
-
{ element: '<div>Item 2</div>', clickable: false, rowData: 'Item 2' },
|
|
143
|
-
];
|
|
144
|
-
await page.waitForChanges();
|
|
145
|
-
const clickableItem = page.root.shadowRoot.querySelector('.clickable');
|
|
146
|
-
clickableItem.dispatchEvent(new Event('click'));
|
|
147
|
-
expect(eventSpy).toHaveBeenCalledWith(expect.objectContaining({
|
|
148
|
-
detail: { name: 'test-list', data: 'Item 1' },
|
|
149
|
-
}));
|
|
150
|
-
});
|
|
151
|
-
it('does not emit listRowClick event when a non-clickable row is clicked', async () => {
|
|
152
|
-
const page = await newSpecPage({
|
|
153
|
-
components: [TttxList],
|
|
154
|
-
html: '<tttx-list></tttx-list>',
|
|
155
|
-
});
|
|
156
|
-
const eventSpy = jest.fn();
|
|
157
|
-
page.doc.addEventListener('listRowClick', eventSpy);
|
|
158
|
-
page.rootInstance.data = [
|
|
159
|
-
{ element: '<div>Item 1</div>', clickable: true, rowData: 'Item 1' },
|
|
160
|
-
{ element: '<div>Item 2</div>', clickable: false, rowData: 'Item 2' },
|
|
161
|
-
];
|
|
162
|
-
await page.waitForChanges();
|
|
163
|
-
const nonClickableItem = page.root.shadowRoot.querySelector(':not(.clickable)');
|
|
164
|
-
await nonClickableItem.dispatchEvent(new Event('click'));
|
|
165
|
-
expect(eventSpy).not.toHaveBeenCalled();
|
|
166
|
-
});
|
|
167
|
-
it('does not emit listRowClick event when a row without rowData is clicked', async () => {
|
|
168
|
-
const page = await newSpecPage({
|
|
169
|
-
components: [TttxList],
|
|
170
|
-
html: '<tttx-list></tttx-list>',
|
|
171
|
-
});
|
|
172
|
-
const eventSpy = jest.fn();
|
|
173
|
-
page.doc.addEventListener('listRowClick', eventSpy);
|
|
174
|
-
page.rootInstance.data = [
|
|
175
|
-
{ element: '<div>Item 1</div>', clickable: true },
|
|
176
|
-
{ element: '<div>Item 2</div>', clickable: false },
|
|
177
|
-
];
|
|
178
|
-
await page.waitForChanges();
|
|
179
|
-
const nonClickableItem = page.root.shadowRoot.querySelector('.clickable');
|
|
180
|
-
await nonClickableItem.dispatchEvent(new Event('click'));
|
|
181
|
-
expect(eventSpy).not.toHaveBeenCalled();
|
|
182
|
-
});
|
|
183
|
-
});
|
package/dist/collection/components/molecules/tttx-standalone-input/test/tttx-standalone-input.e2e.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { newE2EPage } from '@stencil/core/testing';
|
|
2
|
-
describe('tttx-standalone-input', () => {
|
|
3
|
-
it('renders', async () => {
|
|
4
|
-
const page = await newE2EPage();
|
|
5
|
-
await page.setContent('<tttx-standalone-input></tttx-standalone-input>');
|
|
6
|
-
const element = await page.find('tttx-standalone-input');
|
|
7
|
-
expect(element).toHaveClass('hydrated');
|
|
8
|
-
});
|
|
9
|
-
});
|
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
import { newSpecPage } from '@stencil/core/testing';
|
|
2
|
-
import { TttxInput } from '../tttx-standalone-input';
|
|
3
|
-
describe('tttx-standalone-input', () => {
|
|
4
|
-
it('renders', async () => {
|
|
5
|
-
const page = await newSpecPage({
|
|
6
|
-
components: [TttxInput],
|
|
7
|
-
html: '<tttx-standalone-input />',
|
|
8
|
-
});
|
|
9
|
-
expect(page.root).toEqualHtml(`
|
|
10
|
-
<tttx-standalone-input>
|
|
11
|
-
<label class="inputBlock">
|
|
12
|
-
<span class="optional">
|
|
13
|
-
(optional)
|
|
14
|
-
</span>
|
|
15
|
-
<div class="input-container">
|
|
16
|
-
<input class="standalone" type="text">
|
|
17
|
-
<span class="errorBubble">
|
|
18
|
-
<span class="material-symbols-rounded validationicon">
|
|
19
|
-
warning
|
|
20
|
-
</span>
|
|
21
|
-
</span>
|
|
22
|
-
</div>
|
|
23
|
-
</label>
|
|
24
|
-
</tttx-standalone-input>
|
|
25
|
-
`);
|
|
26
|
-
});
|
|
27
|
-
it('renders the input field with the left icon', async () => {
|
|
28
|
-
const page = await newSpecPage({
|
|
29
|
-
components: [TttxInput],
|
|
30
|
-
html: '<tttx-standalone-input iconleft="info" />',
|
|
31
|
-
});
|
|
32
|
-
expect(page.root).toEqualHtml(`
|
|
33
|
-
<tttx-standalone-input iconleft="info">
|
|
34
|
-
<label class="inputBlock">
|
|
35
|
-
<span class="optional">
|
|
36
|
-
(optional)
|
|
37
|
-
</span>
|
|
38
|
-
<div class="icon-left">
|
|
39
|
-
<tttx-icon color="grey" icon="info"></tttx-icon>
|
|
40
|
-
</div>
|
|
41
|
-
<div class="input-container">
|
|
42
|
-
<input class="standalone" type="text">
|
|
43
|
-
<span class="errorBubble">
|
|
44
|
-
<span class="material-symbols-rounded validationicon">
|
|
45
|
-
warning
|
|
46
|
-
</span>
|
|
47
|
-
</span>
|
|
48
|
-
</div>
|
|
49
|
-
</label>
|
|
50
|
-
</tttx-standalone-input>
|
|
51
|
-
`);
|
|
52
|
-
});
|
|
53
|
-
it('renders the input field with the right icon', async () => {
|
|
54
|
-
const page = await newSpecPage({
|
|
55
|
-
components: [TttxInput],
|
|
56
|
-
html: '<tttx-standalone-input iconright="info" />',
|
|
57
|
-
});
|
|
58
|
-
expect(page.root).toEqualHtml(`
|
|
59
|
-
<tttx-standalone-input iconright="info">
|
|
60
|
-
<label class="inputBlock">
|
|
61
|
-
<span class="optional">
|
|
62
|
-
(optional)
|
|
63
|
-
</span>
|
|
64
|
-
<div class="input-container">
|
|
65
|
-
<input class="standalone" type="text">
|
|
66
|
-
<div class="icon-right">
|
|
67
|
-
<tttx-icon color="grey" icon="info"></tttx-icon>
|
|
68
|
-
</div>
|
|
69
|
-
<span class="errorBubble">
|
|
70
|
-
<span class="material-symbols-rounded validationicon">
|
|
71
|
-
warning
|
|
72
|
-
</span>
|
|
73
|
-
</span>
|
|
74
|
-
</div>
|
|
75
|
-
</label>
|
|
76
|
-
</tttx-standalone-input>
|
|
77
|
-
`);
|
|
78
|
-
});
|
|
79
|
-
it('renders the input field with an error message', async () => {
|
|
80
|
-
const page = await newSpecPage({
|
|
81
|
-
components: [TttxInput],
|
|
82
|
-
html: '<tttx-standalone-input required showerrormsg errormsg="The field is required" />',
|
|
83
|
-
});
|
|
84
|
-
expect(page.root).toEqualHtml(`
|
|
85
|
-
<tttx-standalone-input errormsg="The field is required" required="" showerrormsg="">
|
|
86
|
-
<label class="inputBlock">
|
|
87
|
-
<div class="input-container">
|
|
88
|
-
<input class="invalid standalone" required="" type="text">
|
|
89
|
-
<span class="errorBubble visible">
|
|
90
|
-
<span class="material-symbols-rounded validationicon">
|
|
91
|
-
warning
|
|
92
|
-
</span>
|
|
93
|
-
The field is required
|
|
94
|
-
</span>
|
|
95
|
-
</div>
|
|
96
|
-
</label>
|
|
97
|
-
</tttx-standalone-input>
|
|
98
|
-
`);
|
|
99
|
-
});
|
|
100
|
-
it('renders the label as inline', async () => {
|
|
101
|
-
const page = await newSpecPage({
|
|
102
|
-
components: [TttxInput],
|
|
103
|
-
html: '<tttx-standalone-input inline />',
|
|
104
|
-
});
|
|
105
|
-
expect(page.root).toEqualHtml(`
|
|
106
|
-
<tttx-standalone-input inline="">
|
|
107
|
-
<label class="inputInline">
|
|
108
|
-
<span class="optional">
|
|
109
|
-
(optional)
|
|
110
|
-
</span>
|
|
111
|
-
<div class="input-container">
|
|
112
|
-
<input class="standalone" type="text">
|
|
113
|
-
<span class="errorBubble">
|
|
114
|
-
<span class="material-symbols-rounded validationicon">
|
|
115
|
-
warning
|
|
116
|
-
</span>
|
|
117
|
-
</span>
|
|
118
|
-
</div>
|
|
119
|
-
</label>
|
|
120
|
-
</tttx-standalone-input>
|
|
121
|
-
`);
|
|
122
|
-
});
|
|
123
|
-
it('renders the input with an icon within the field', async () => {
|
|
124
|
-
const page = await newSpecPage({
|
|
125
|
-
components: [TttxInput],
|
|
126
|
-
html: '<tttx-standalone-input inputicon="search" />',
|
|
127
|
-
});
|
|
128
|
-
expect(page.root).toEqualHtml(`
|
|
129
|
-
<tttx-standalone-input inputicon="search">
|
|
130
|
-
<label class="inputBlock">
|
|
131
|
-
<span class="optional">
|
|
132
|
-
(optional)
|
|
133
|
-
</span>
|
|
134
|
-
<div class="input-container">
|
|
135
|
-
<tttx-icon class="input-icon" icon="search" color="grey"></tttx-icon>
|
|
136
|
-
<input class="standalone" type="text">
|
|
137
|
-
<span class="errorBubble">
|
|
138
|
-
<span class="material-symbols-rounded validationicon">
|
|
139
|
-
warning
|
|
140
|
-
</span>
|
|
141
|
-
</span>
|
|
142
|
-
</div>
|
|
143
|
-
</label>
|
|
144
|
-
</tttx-standalone-input>
|
|
145
|
-
`);
|
|
146
|
-
});
|
|
147
|
-
it('renders the input without the errorbubble', async () => {
|
|
148
|
-
const page = await newSpecPage({
|
|
149
|
-
components: [TttxInput],
|
|
150
|
-
html: '<tttx-standalone-input showerrorbubble="false" />',
|
|
151
|
-
});
|
|
152
|
-
expect(page.root).toEqualHtml(`
|
|
153
|
-
<tttx-standalone-input showerrorbubble="false">
|
|
154
|
-
<label class="inputBlock">
|
|
155
|
-
<span class="optional">
|
|
156
|
-
(optional)
|
|
157
|
-
</span>
|
|
158
|
-
<div class="input-container">
|
|
159
|
-
<input class="standalone" type="text">
|
|
160
|
-
</div>
|
|
161
|
-
</label>
|
|
162
|
-
</tttx-standalone-input>
|
|
163
|
-
`);
|
|
164
|
-
});
|
|
165
|
-
it('can trigger onInput handler', async () => {
|
|
166
|
-
const page = await newSpecPage({
|
|
167
|
-
components: [TttxInput],
|
|
168
|
-
html: '<tttx-standalone-input />',
|
|
169
|
-
});
|
|
170
|
-
const callbackFn = jest.fn();
|
|
171
|
-
page.doc.addEventListener('valueChanged', callbackFn);
|
|
172
|
-
const input = page.root.querySelector('input');
|
|
173
|
-
input.value = 'a';
|
|
174
|
-
const event = new CustomEvent('input', { composed: true, bubbles: true });
|
|
175
|
-
input.dispatchEvent(event);
|
|
176
|
-
expect(callbackFn).toHaveBeenCalled();
|
|
177
|
-
});
|
|
178
|
-
it('can trigger onFocus handler', async () => {
|
|
179
|
-
const page = await newSpecPage({
|
|
180
|
-
components: [TttxInput],
|
|
181
|
-
html: '<tttx-standalone-input />',
|
|
182
|
-
});
|
|
183
|
-
const callbackFn = jest.fn();
|
|
184
|
-
page.doc.addEventListener('focusChanged', callbackFn);
|
|
185
|
-
const input = page.root.querySelector('input');
|
|
186
|
-
input.focus();
|
|
187
|
-
const event = new CustomEvent('focus', { composed: true, bubbles: true });
|
|
188
|
-
input.dispatchEvent(event);
|
|
189
|
-
expect(callbackFn).toHaveBeenCalled();
|
|
190
|
-
});
|
|
191
|
-
it('can trigger onBlur handler', async () => {
|
|
192
|
-
const page = await newSpecPage({
|
|
193
|
-
components: [TttxInput],
|
|
194
|
-
html: '<tttx-standalone-input />',
|
|
195
|
-
});
|
|
196
|
-
const callbackFn = jest.fn();
|
|
197
|
-
page.doc.addEventListener('blurChanged', callbackFn);
|
|
198
|
-
const input = page.root.querySelector('input');
|
|
199
|
-
input.blur();
|
|
200
|
-
const event = new CustomEvent('blur', { composed: true, bubbles: true });
|
|
201
|
-
input.dispatchEvent(event);
|
|
202
|
-
expect(callbackFn).toHaveBeenCalled();
|
|
203
|
-
});
|
|
204
|
-
it('can trigger onInvalid handler', async () => {
|
|
205
|
-
const page = await newSpecPage({
|
|
206
|
-
components: [TttxInput],
|
|
207
|
-
html: '<tttx-standalone-input />',
|
|
208
|
-
});
|
|
209
|
-
const callbackFn = jest.fn();
|
|
210
|
-
page.doc.addEventListener('invalidChanged', callbackFn);
|
|
211
|
-
const input = page.root.querySelector('input');
|
|
212
|
-
// Doesn't work:
|
|
213
|
-
// input.setCustomValidity('required');
|
|
214
|
-
// input.checkValidity();
|
|
215
|
-
const event = new CustomEvent('invalid', { composed: true, bubbles: true });
|
|
216
|
-
input.dispatchEvent(event);
|
|
217
|
-
expect(callbackFn).toHaveBeenCalled();
|
|
218
|
-
});
|
|
219
|
-
});
|
|
File without changes
|