@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
package/dist/collection/components/atoms/tttx-keyvalue-block/test/tttx-keyvalue-block.spec.js
DELETED
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
import { h } from '@stencil/core';
|
|
2
|
-
import { newSpecPage } from '@stencil/core/testing';
|
|
3
|
-
import { TttxKeyvalueBlock } from '../tttx-keyvalue-block';
|
|
4
|
-
describe('tttx-keyvalue-block', () => {
|
|
5
|
-
it('renders multiple key value pairs', async () => {
|
|
6
|
-
const keyValuePair = {
|
|
7
|
-
'Name': 'John Doe',
|
|
8
|
-
'Date of birth': '14 Jan 1981',
|
|
9
|
-
'Start of postcode': 'AB10'
|
|
10
|
-
};
|
|
11
|
-
const page = await newSpecPage({
|
|
12
|
-
components: [TttxKeyvalueBlock],
|
|
13
|
-
html: `<tttx-keyvalue-block keyvalues='${JSON.stringify(keyValuePair)}' />`
|
|
14
|
-
});
|
|
15
|
-
await page.waitForChanges();
|
|
16
|
-
expect(page.root).toEqualHtml(`
|
|
17
|
-
<tttx-keyvalue-block keyvalues='{"Name":"John Doe","Date of birth":"14 Jan 1981","Start of postcode":"AB10"}'>
|
|
18
|
-
<mock:shadow-root>
|
|
19
|
-
<dl>
|
|
20
|
-
<dt>
|
|
21
|
-
Name
|
|
22
|
-
</dt>
|
|
23
|
-
<dd>
|
|
24
|
-
John Doe
|
|
25
|
-
</dd>
|
|
26
|
-
<dt>
|
|
27
|
-
Date of birth
|
|
28
|
-
</dt>
|
|
29
|
-
<dd>
|
|
30
|
-
14 Jan 1981
|
|
31
|
-
</dd>
|
|
32
|
-
<dt>
|
|
33
|
-
Start of postcode
|
|
34
|
-
</dt>
|
|
35
|
-
<dd>
|
|
36
|
-
AB10
|
|
37
|
-
</dd>
|
|
38
|
-
</dl>
|
|
39
|
-
</mock:shadow-root>
|
|
40
|
-
</tttx-keyvalue-block>
|
|
41
|
-
`);
|
|
42
|
-
});
|
|
43
|
-
it('renders multiple key value pairs from a stencil template', async () => {
|
|
44
|
-
const keyValuePair = {
|
|
45
|
-
'Name': 'John Doe',
|
|
46
|
-
'Date of birth': '14 Jan 1981',
|
|
47
|
-
'Start of postcode': 'AB10'
|
|
48
|
-
};
|
|
49
|
-
const page = await newSpecPage({
|
|
50
|
-
components: [TttxKeyvalueBlock],
|
|
51
|
-
template: () => (h("tttx-keyvalue-block", { keyvalues: keyValuePair }))
|
|
52
|
-
});
|
|
53
|
-
await page.waitForChanges();
|
|
54
|
-
expect(page.root).toEqualHtml(`
|
|
55
|
-
<tttx-keyvalue-block>
|
|
56
|
-
<mock:shadow-root>
|
|
57
|
-
<dl>
|
|
58
|
-
<dt>
|
|
59
|
-
Name
|
|
60
|
-
</dt>
|
|
61
|
-
<dd>
|
|
62
|
-
John Doe
|
|
63
|
-
</dd>
|
|
64
|
-
<dt>
|
|
65
|
-
Date of birth
|
|
66
|
-
</dt>
|
|
67
|
-
<dd>
|
|
68
|
-
14 Jan 1981
|
|
69
|
-
</dd>
|
|
70
|
-
<dt>
|
|
71
|
-
Start of postcode
|
|
72
|
-
</dt>
|
|
73
|
-
<dd>
|
|
74
|
-
AB10
|
|
75
|
-
</dd>
|
|
76
|
-
</dl>
|
|
77
|
-
</mock:shadow-root>
|
|
78
|
-
</tttx-keyvalue-block>
|
|
79
|
-
`);
|
|
80
|
-
});
|
|
81
|
-
it('renders with missing keyvalue object', async () => {
|
|
82
|
-
const page = await newSpecPage({
|
|
83
|
-
components: [TttxKeyvalueBlock],
|
|
84
|
-
template: () => (h("tttx-keyvalue-block", null))
|
|
85
|
-
});
|
|
86
|
-
await page.waitForChanges();
|
|
87
|
-
expect(page.root).toEqualHtml(`
|
|
88
|
-
<tttx-keyvalue-block>
|
|
89
|
-
<mock:shadow-root>
|
|
90
|
-
</mock:shadow-root>
|
|
91
|
-
</tttx-keyvalue-block>
|
|
92
|
-
`);
|
|
93
|
-
});
|
|
94
|
-
it('renders an array of key value subtitles', async () => {
|
|
95
|
-
const keyValueArray = [
|
|
96
|
-
{ title: 'title', subTitle: 'sub', data: 'data' },
|
|
97
|
-
{ title: 'title2', subTitle: 'sub2', data: 'data2' }
|
|
98
|
-
];
|
|
99
|
-
const page = await newSpecPage({
|
|
100
|
-
components: [TttxKeyvalueBlock],
|
|
101
|
-
html: `<tttx-keyvalue-block keyvalues='${JSON.stringify(keyValueArray)}' />`
|
|
102
|
-
});
|
|
103
|
-
await page.waitForChanges();
|
|
104
|
-
expect(page.root).toEqualHtml(`
|
|
105
|
-
<tttx-keyvalue-block keyvalues='[{"title":"title","subTitle":"sub","data":"data"},{"title":"title2","subTitle":"sub2","data":"data2"}]'>
|
|
106
|
-
<mock:shadow-root>
|
|
107
|
-
<dl>
|
|
108
|
-
<dt class="mainTitle">
|
|
109
|
-
title
|
|
110
|
-
</dt>
|
|
111
|
-
<dt class="subTitle">
|
|
112
|
-
sub
|
|
113
|
-
</dt>
|
|
114
|
-
<dd>
|
|
115
|
-
data
|
|
116
|
-
</dd>
|
|
117
|
-
<dt class="mainTitle">
|
|
118
|
-
title2
|
|
119
|
-
</dt>
|
|
120
|
-
<dt class="subTitle">
|
|
121
|
-
sub2
|
|
122
|
-
</dt>
|
|
123
|
-
<dd>
|
|
124
|
-
data2
|
|
125
|
-
</dd>
|
|
126
|
-
</dl>
|
|
127
|
-
</mock:shadow-root>
|
|
128
|
-
</tttx-keyvalue-block>
|
|
129
|
-
`);
|
|
130
|
-
});
|
|
131
|
-
it('renders multiple horizontal key value pairs', async () => {
|
|
132
|
-
const keyValuePair = {
|
|
133
|
-
'Name': 'John Doe',
|
|
134
|
-
'Date of birth': '14 Jan 1981',
|
|
135
|
-
'Start of postcode': 'AB10'
|
|
136
|
-
};
|
|
137
|
-
const page = await newSpecPage({
|
|
138
|
-
components: [TttxKeyvalueBlock],
|
|
139
|
-
html: `<tttx-keyvalue-block horizontal="true" keyvalues='${JSON.stringify(keyValuePair)}' />`
|
|
140
|
-
});
|
|
141
|
-
await page.waitForChanges();
|
|
142
|
-
expect(page.root).toEqualHtml(`
|
|
143
|
-
<tttx-keyvalue-block horizontal="true" keyvalues='{"Name":"John Doe","Date of birth":"14 Jan 1981","Start of postcode":"AB10"}'>
|
|
144
|
-
<mock:shadow-root>
|
|
145
|
-
<dl class="horizontal">
|
|
146
|
-
<div>
|
|
147
|
-
<dt>
|
|
148
|
-
Name
|
|
149
|
-
</dt>
|
|
150
|
-
<dd>
|
|
151
|
-
John Doe
|
|
152
|
-
</dd>
|
|
153
|
-
</div>
|
|
154
|
-
<div>
|
|
155
|
-
<dt>
|
|
156
|
-
Date of birth
|
|
157
|
-
</dt>
|
|
158
|
-
<dd>
|
|
159
|
-
14 Jan 1981
|
|
160
|
-
</dd>
|
|
161
|
-
</div>
|
|
162
|
-
<div>
|
|
163
|
-
<dt>
|
|
164
|
-
Start of postcode
|
|
165
|
-
</dt>
|
|
166
|
-
<dd>
|
|
167
|
-
AB10
|
|
168
|
-
</dd>
|
|
169
|
-
</div>
|
|
170
|
-
</dl>
|
|
171
|
-
</mock:shadow-root>
|
|
172
|
-
</tttx-keyvalue-block>
|
|
173
|
-
`);
|
|
174
|
-
});
|
|
175
|
-
it('renders an array of horizontal key value subtitles', async () => {
|
|
176
|
-
const keyValueArray = [
|
|
177
|
-
{ title: 'title', subTitle: 'sub', data: 'data' },
|
|
178
|
-
{ title: 'title2', subTitle: 'sub2', data: 'data2' }
|
|
179
|
-
];
|
|
180
|
-
const page = await newSpecPage({
|
|
181
|
-
components: [TttxKeyvalueBlock],
|
|
182
|
-
html: `<tttx-keyvalue-block horizontal="true" keyvalues='${JSON.stringify(keyValueArray)}' />`
|
|
183
|
-
});
|
|
184
|
-
await page.waitForChanges();
|
|
185
|
-
expect(page.root).toEqualHtml(`
|
|
186
|
-
<tttx-keyvalue-block horizontal="true" keyvalues='[{"title":"title","subTitle":"sub","data":"data"},{"title":"title2","subTitle":"sub2","data":"data2"}]'>
|
|
187
|
-
<mock:shadow-root>
|
|
188
|
-
<dl class="horizontal">
|
|
189
|
-
<div>
|
|
190
|
-
<dt class="mainTitle">
|
|
191
|
-
title
|
|
192
|
-
</dt>
|
|
193
|
-
<dt class="subTitle">
|
|
194
|
-
sub
|
|
195
|
-
</dt>
|
|
196
|
-
<dd>
|
|
197
|
-
data
|
|
198
|
-
</dd>
|
|
199
|
-
</div>
|
|
200
|
-
<div>
|
|
201
|
-
<dt class="mainTitle">
|
|
202
|
-
title2
|
|
203
|
-
</dt>
|
|
204
|
-
<dt class="subTitle">
|
|
205
|
-
sub2
|
|
206
|
-
</dt>
|
|
207
|
-
<dd>
|
|
208
|
-
data2
|
|
209
|
-
</dd>
|
|
210
|
-
</div>
|
|
211
|
-
</dl>
|
|
212
|
-
</mock:shadow-root>
|
|
213
|
-
</tttx-keyvalue-block>
|
|
214
|
-
`);
|
|
215
|
-
});
|
|
216
|
-
});
|
package/dist/collection/components/atoms/tttx-loading-spinner/Test/tttx-loading-spinner.spec.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { newSpecPage } from '@stencil/core/testing';
|
|
2
|
-
import { TttxLoadingSpinner } from '../tttx-loading-spinner';
|
|
3
|
-
describe('tttx-loading-spinner', () => {
|
|
4
|
-
it('renders the loading text when the loading message prop is set to true', async () => {
|
|
5
|
-
const page = await newSpecPage({
|
|
6
|
-
components: [TttxLoadingSpinner],
|
|
7
|
-
html: '<tttx-loading-spinner></tttx-loading-spinner>',
|
|
8
|
-
});
|
|
9
|
-
page.rootInstance.loadingMessage = true;
|
|
10
|
-
await page.waitForChanges();
|
|
11
|
-
expect(page.root).toEqualHtml(`
|
|
12
|
-
<tttx-loading-spinner>
|
|
13
|
-
<mock:shadow-root>
|
|
14
|
-
<div class='spinner-container'><div class="loading-box"><span class='spinner large'></span></div><div class='loading-text'>Loading, please wait...</div></div>
|
|
15
|
-
</mock:shadow-root>
|
|
16
|
-
</tttx-loading-spinner>
|
|
17
|
-
`);
|
|
18
|
-
});
|
|
19
|
-
it('renders without the loading text when the loading message prop is set to false', async () => {
|
|
20
|
-
const page = await newSpecPage({
|
|
21
|
-
components: [TttxLoadingSpinner],
|
|
22
|
-
html: '<tttx-loading-spinner></tttx-loading-spinner>',
|
|
23
|
-
});
|
|
24
|
-
page.rootInstance.loadingMessage = false;
|
|
25
|
-
await page.waitForChanges();
|
|
26
|
-
expect(page.root).toEqualHtml(`
|
|
27
|
-
<tttx-loading-spinner>
|
|
28
|
-
<mock:shadow-root>
|
|
29
|
-
<div class='spinner-container'><div class="loading-box"><span class='spinner large'></span></div></div>
|
|
30
|
-
</mock:shadow-root>
|
|
31
|
-
</tttx-loading-spinner>
|
|
32
|
-
`);
|
|
33
|
-
});
|
|
34
|
-
it('renders the small spinner when the size prop is set to small', async () => {
|
|
35
|
-
const page = await newSpecPage({
|
|
36
|
-
components: [TttxLoadingSpinner],
|
|
37
|
-
html: '<tttx-loading-spinner></tttx-loading-spinner>',
|
|
38
|
-
});
|
|
39
|
-
page.rootInstance.size = 'small';
|
|
40
|
-
await page.waitForChanges();
|
|
41
|
-
expect(page.root).toEqualHtml(`
|
|
42
|
-
<tttx-loading-spinner>
|
|
43
|
-
<mock:shadow-root>
|
|
44
|
-
<div class='spinner-container'><div class="loading-box"><span class='spinner small'></span></div></div>
|
|
45
|
-
</mock:shadow-root>
|
|
46
|
-
</tttx-loading-spinner>
|
|
47
|
-
`);
|
|
48
|
-
});
|
|
49
|
-
it('renders the large spinner when the size prop is set to large', async () => {
|
|
50
|
-
const page = await newSpecPage({
|
|
51
|
-
components: [TttxLoadingSpinner],
|
|
52
|
-
html: '<tttx-loading-spinner></tttx-loading-spinner>',
|
|
53
|
-
});
|
|
54
|
-
page.rootInstance.size = 'large';
|
|
55
|
-
await page.waitForChanges();
|
|
56
|
-
expect(page.root).toEqualHtml(`
|
|
57
|
-
<tttx-loading-spinner>
|
|
58
|
-
<mock:shadow-root>
|
|
59
|
-
<div class='spinner-container'><div class="loading-box"><span class='spinner large'></span></div></div>
|
|
60
|
-
</mock:shadow-root>
|
|
61
|
-
</tttx-loading-spinner>
|
|
62
|
-
`);
|
|
63
|
-
});
|
|
64
|
-
});
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import setErrorState from './setErrorState';
|
|
2
|
-
describe('setErrorState', () => {
|
|
3
|
-
let target;
|
|
4
|
-
let errorBubble;
|
|
5
|
-
beforeEach(() => {
|
|
6
|
-
target = document.createElement('input');
|
|
7
|
-
errorBubble = document.createElement('div');
|
|
8
|
-
errorBubble.className = 'errorBubble';
|
|
9
|
-
target.parentElement = document.createElement('div');
|
|
10
|
-
target.parentElement.appendChild(errorBubble);
|
|
11
|
-
});
|
|
12
|
-
afterEach(() => {
|
|
13
|
-
target = null;
|
|
14
|
-
errorBubble = null;
|
|
15
|
-
});
|
|
16
|
-
test('should set error state correctly when hasError is true', () => {
|
|
17
|
-
setErrorState(target, true, 'Invalid value');
|
|
18
|
-
expect(target.className).toBe('invalid');
|
|
19
|
-
expect(errorBubble.innerHTML).toBe('<span class="material-symbols-rounded">warning</span>Invalid value');
|
|
20
|
-
});
|
|
21
|
-
test('should clear error state correctly when hasError is false', () => {
|
|
22
|
-
target.className = 'invalid';
|
|
23
|
-
errorBubble.innerHTML = '<span class="material-symbols-rounded">warning</span>Invalid value';
|
|
24
|
-
setErrorState(target, false, '');
|
|
25
|
-
expect(target.className).toBe('');
|
|
26
|
-
expect(errorBubble.innerHTML).toBe('');
|
|
27
|
-
});
|
|
28
|
-
test('should set error state correctly with custom error message', () => {
|
|
29
|
-
setErrorState(target, true, 'Custom error message');
|
|
30
|
-
expect(target.className).toBe('invalid');
|
|
31
|
-
expect(errorBubble.innerHTML).toBe('<span class="material-symbols-rounded">warning</span>Custom error message');
|
|
32
|
-
});
|
|
33
|
-
test('should set error state correctly with no error message', () => {
|
|
34
|
-
setErrorState(target, true, '');
|
|
35
|
-
expect(target.className).toBe('invalid');
|
|
36
|
-
expect(errorBubble.innerHTML).toBe('<span class="material-symbols-rounded">warning</span> ');
|
|
37
|
-
});
|
|
38
|
-
});
|
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
import validityCheck from './validityCheck';
|
|
2
|
-
// badInput
|
|
3
|
-
// customError
|
|
4
|
-
// patternMismatch
|
|
5
|
-
// rangeOverflow
|
|
6
|
-
// rangeUnderflow
|
|
7
|
-
// stepMismatch
|
|
8
|
-
// tooLong
|
|
9
|
-
// tooShort
|
|
10
|
-
// typeMismatch
|
|
11
|
-
// valid
|
|
12
|
-
// valueMissing
|
|
13
|
-
describe('validityCheck', () => {
|
|
14
|
-
it('should return a valid response when there are no validation issues', async () => {
|
|
15
|
-
const preventDefault = jest.fn();
|
|
16
|
-
const event = {
|
|
17
|
-
target: {
|
|
18
|
-
value: 'test',
|
|
19
|
-
validity: {
|
|
20
|
-
valid: true
|
|
21
|
-
},
|
|
22
|
-
dataset: {}
|
|
23
|
-
},
|
|
24
|
-
preventDefault
|
|
25
|
-
};
|
|
26
|
-
const result = validityCheck(event);
|
|
27
|
-
expect(preventDefault).toHaveBeenCalledTimes(1);
|
|
28
|
-
expect(result).toStrictEqual({
|
|
29
|
-
"errorMessage": "",
|
|
30
|
-
"hasError": false,
|
|
31
|
-
"target": event.target
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
it('should return the required property when there is a value missing', async () => {
|
|
35
|
-
const preventDefault = jest.fn();
|
|
36
|
-
const event = {
|
|
37
|
-
target: {
|
|
38
|
-
dataset: {
|
|
39
|
-
required: 'This is required'
|
|
40
|
-
},
|
|
41
|
-
value: 'test',
|
|
42
|
-
validity: {
|
|
43
|
-
valid: false,
|
|
44
|
-
valueMissing: true
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
preventDefault
|
|
48
|
-
};
|
|
49
|
-
const result = validityCheck(event);
|
|
50
|
-
expect(preventDefault).toHaveBeenCalledTimes(1);
|
|
51
|
-
expect(result).toStrictEqual({
|
|
52
|
-
"errorMessage": "This is required",
|
|
53
|
-
"hasError": true,
|
|
54
|
-
"target": event.target
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
it('should return a default error message property when there is a value missing', async () => {
|
|
58
|
-
const preventDefault = jest.fn();
|
|
59
|
-
const event = {
|
|
60
|
-
target: {
|
|
61
|
-
dataset: {},
|
|
62
|
-
value: 'test',
|
|
63
|
-
validity: {
|
|
64
|
-
valid: false,
|
|
65
|
-
valueMissing: true
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
preventDefault
|
|
69
|
-
};
|
|
70
|
-
const result = validityCheck(event);
|
|
71
|
-
expect(preventDefault).toHaveBeenCalledTimes(1);
|
|
72
|
-
expect(result).toStrictEqual({
|
|
73
|
-
"errorMessage": 'This field is required',
|
|
74
|
-
"hasError": true,
|
|
75
|
-
"target": event.target
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
it('should return the pattern property when there is a patternMismatch', async () => {
|
|
79
|
-
const preventDefault = jest.fn();
|
|
80
|
-
const event = {
|
|
81
|
-
target: {
|
|
82
|
-
dataset: {
|
|
83
|
-
pattern: 'Incorrect format CUSTOM'
|
|
84
|
-
},
|
|
85
|
-
value: 'test',
|
|
86
|
-
validity: {
|
|
87
|
-
valid: false,
|
|
88
|
-
patternMismatch: true
|
|
89
|
-
}
|
|
90
|
-
},
|
|
91
|
-
preventDefault
|
|
92
|
-
};
|
|
93
|
-
const result = validityCheck(event);
|
|
94
|
-
expect(preventDefault).toHaveBeenCalledTimes(1);
|
|
95
|
-
expect(result).toStrictEqual({
|
|
96
|
-
"errorMessage": "Incorrect format CUSTOM",
|
|
97
|
-
"hasError": true,
|
|
98
|
-
"target": event.target
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
it('should return the a default error message when there is a patternMismatch', async () => {
|
|
102
|
-
const preventDefault = jest.fn();
|
|
103
|
-
const event = {
|
|
104
|
-
target: {
|
|
105
|
-
dataset: {},
|
|
106
|
-
value: 'test',
|
|
107
|
-
validity: {
|
|
108
|
-
valid: false,
|
|
109
|
-
patternMismatch: true
|
|
110
|
-
}
|
|
111
|
-
},
|
|
112
|
-
preventDefault
|
|
113
|
-
};
|
|
114
|
-
const result = validityCheck(event);
|
|
115
|
-
expect(preventDefault).toHaveBeenCalledTimes(1);
|
|
116
|
-
expect(result).toStrictEqual({
|
|
117
|
-
"errorMessage": 'Incorrect format',
|
|
118
|
-
"hasError": true,
|
|
119
|
-
"target": event.target
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
it('should return the badinput error message property when there is a badInput', async () => {
|
|
123
|
-
const preventDefault = jest.fn();
|
|
124
|
-
const event = {
|
|
125
|
-
target: {
|
|
126
|
-
dataset: {
|
|
127
|
-
badinput: 'There is a bad input'
|
|
128
|
-
},
|
|
129
|
-
value: 'test',
|
|
130
|
-
validity: {
|
|
131
|
-
valid: false,
|
|
132
|
-
badInput: true
|
|
133
|
-
}
|
|
134
|
-
},
|
|
135
|
-
preventDefault
|
|
136
|
-
};
|
|
137
|
-
const result = validityCheck(event);
|
|
138
|
-
expect(preventDefault).toHaveBeenCalledTimes(1);
|
|
139
|
-
expect(result).toStrictEqual({
|
|
140
|
-
"errorMessage": "There is a bad input",
|
|
141
|
-
"hasError": true,
|
|
142
|
-
"target": event.target
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
it('should return a default error message property when there is a badInput', async () => {
|
|
146
|
-
const preventDefault = jest.fn();
|
|
147
|
-
const event = {
|
|
148
|
-
target: {
|
|
149
|
-
value: 'test',
|
|
150
|
-
validity: {
|
|
151
|
-
valid: false,
|
|
152
|
-
badInput: true
|
|
153
|
-
},
|
|
154
|
-
dataset: {}
|
|
155
|
-
},
|
|
156
|
-
preventDefault
|
|
157
|
-
};
|
|
158
|
-
const result = validityCheck(event);
|
|
159
|
-
expect(preventDefault).toHaveBeenCalledTimes(1);
|
|
160
|
-
expect(result).toStrictEqual({
|
|
161
|
-
"errorMessage": 'Wrong input type',
|
|
162
|
-
"hasError": true,
|
|
163
|
-
"target": event.target
|
|
164
|
-
});
|
|
165
|
-
});
|
|
166
|
-
it('should return a message for an item out of range (underflow) with custom message', async () => {
|
|
167
|
-
const preventDefault = jest.fn();
|
|
168
|
-
const event = {
|
|
169
|
-
target: {
|
|
170
|
-
value: '0',
|
|
171
|
-
validity: {
|
|
172
|
-
valid: false,
|
|
173
|
-
rangeOverflow: true
|
|
174
|
-
},
|
|
175
|
-
dataset: {
|
|
176
|
-
range: 'Value is out of range'
|
|
177
|
-
}
|
|
178
|
-
},
|
|
179
|
-
preventDefault
|
|
180
|
-
};
|
|
181
|
-
const result = validityCheck(event);
|
|
182
|
-
expect(preventDefault).toHaveBeenCalledTimes(1);
|
|
183
|
-
expect(result).toStrictEqual({
|
|
184
|
-
"errorMessage": "Value is out of range",
|
|
185
|
-
"hasError": true,
|
|
186
|
-
"target": event.target
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
it('should return a message for an item out of range (underflow)', async () => {
|
|
190
|
-
const preventDefault = jest.fn();
|
|
191
|
-
const event = {
|
|
192
|
-
target: {
|
|
193
|
-
value: '0',
|
|
194
|
-
validity: {
|
|
195
|
-
valid: false,
|
|
196
|
-
rangeOverflow: true
|
|
197
|
-
},
|
|
198
|
-
dataset: {}
|
|
199
|
-
},
|
|
200
|
-
preventDefault
|
|
201
|
-
};
|
|
202
|
-
const result = validityCheck(event);
|
|
203
|
-
expect(preventDefault).toHaveBeenCalledTimes(1);
|
|
204
|
-
expect(result).toStrictEqual({
|
|
205
|
-
"errorMessage": "Invalid value",
|
|
206
|
-
"hasError": true,
|
|
207
|
-
"target": event.target
|
|
208
|
-
});
|
|
209
|
-
});
|
|
210
|
-
// it('target.validity.rangeOverflow', async () => {
|
|
211
|
-
// });
|
|
212
|
-
// it('target.validity.rangeUnderflow', async () => {
|
|
213
|
-
// });
|
|
214
|
-
});
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { newE2EPage } from '@stencil/core/testing';
|
|
2
|
-
describe('tttx-form', () => {
|
|
3
|
-
it('renders', async () => {
|
|
4
|
-
const page = await newE2EPage();
|
|
5
|
-
await page.setContent('<tttx-form></tttx-form>');
|
|
6
|
-
const element = await page.find('tttx-form');
|
|
7
|
-
expect(element).toHaveClass('hydrated');
|
|
8
|
-
});
|
|
9
|
-
});
|