@decidables/decidables-elements 0.0.1

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.
Files changed (49) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +54 -0
  3. package/gulpfile.js +25 -0
  4. package/lib/decidablesElements.esm.js +4889 -0
  5. package/lib/decidablesElements.esm.js.map +1 -0
  6. package/lib/decidablesElements.esm.min.js +13 -0
  7. package/lib/decidablesElements.esm.min.js.map +1 -0
  8. package/lib/decidablesElements.umd.js +4907 -0
  9. package/lib/decidablesElements.umd.js.map +1 -0
  10. package/lib/decidablesElements.umd.min.js +13 -0
  11. package/lib/decidablesElements.umd.min.js.map +1 -0
  12. package/package.json +46 -0
  13. package/src/button.js +93 -0
  14. package/src/converter-array.js +15 -0
  15. package/src/converter-set.js +15 -0
  16. package/src/decidables-element.js +264 -0
  17. package/src/index.js +11 -0
  18. package/src/slider.js +333 -0
  19. package/src/spinner.js +149 -0
  20. package/src/switch.js +179 -0
  21. package/src/toggle-option.js +163 -0
  22. package/src/toggle.js +58 -0
  23. package/test/button.test.js +29 -0
  24. package/test/converter-array.test.js +14 -0
  25. package/test/converter-set.test.js +15 -0
  26. package/test/coverage/lcov-report/base.css +224 -0
  27. package/test/coverage/lcov-report/block-navigation.js +87 -0
  28. package/test/coverage/lcov-report/button.js.html +364 -0
  29. package/test/coverage/lcov-report/converter-array.js.html +130 -0
  30. package/test/coverage/lcov-report/converter-set.js.html +130 -0
  31. package/test/coverage/lcov-report/decidables-element.js.html +877 -0
  32. package/test/coverage/lcov-report/favicon.png +0 -0
  33. package/test/coverage/lcov-report/index.html +236 -0
  34. package/test/coverage/lcov-report/prettify.css +1 -0
  35. package/test/coverage/lcov-report/prettify.js +2 -0
  36. package/test/coverage/lcov-report/slider.js.html +1084 -0
  37. package/test/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  38. package/test/coverage/lcov-report/sorter.js +196 -0
  39. package/test/coverage/lcov-report/spinner.js.html +532 -0
  40. package/test/coverage/lcov-report/switch.js.html +622 -0
  41. package/test/coverage/lcov-report/toggle-option.js.html +574 -0
  42. package/test/coverage/lcov-report/toggle.js.html +259 -0
  43. package/test/coverage/lcov.info +1480 -0
  44. package/test/decidables-element.test.js +10 -0
  45. package/test/slider.test.js +64 -0
  46. package/test/spinner.test.js +55 -0
  47. package/test/switch.test.js +71 -0
  48. package/test/toggle-option.test.js +62 -0
  49. package/test/toggle.test.js +98 -0
@@ -0,0 +1,10 @@
1
+ import {expect} from '@open-wc/testing';
2
+
3
+ import DecidablesElement from '../src/decidables-element';
4
+
5
+ describe('decidables-element', () => {
6
+ it('can provide a uniqueId', async () => {
7
+ const uniqueId = DecidablesElement.uniqueId; // eslint-disable-line prefer-destructuring
8
+ expect(uniqueId).to.equal(1);
9
+ });
10
+ });
@@ -0,0 +1,64 @@
1
+ import {expect, fixture, html} from '@open-wc/testing';
2
+
3
+ import '../src/slider';
4
+
5
+ describe('decidables-slider', () => {
6
+ it('has a shadowDom', async () => {
7
+ const el = await fixture(html` <decidables-slider>Slide</decidables-slider> `);
8
+
9
+ expect(el).shadowDom.to.equal(`
10
+ <label for="decidables-1-slider">
11
+ <slot></slot>
12
+ </label>
13
+ <div class="range">
14
+ <input type="range" id="decidables-1-slider">
15
+ </div>
16
+ <decidables-spinner></decidables-spinner>
17
+ `);
18
+ });
19
+
20
+ it('has a lightDom', async () => {
21
+ const el = await fixture(html` <decidables-slider>Slide</decidables-slider> `);
22
+
23
+ expect(el).lightDom.to.equal(`
24
+ Slide
25
+ `);
26
+ });
27
+
28
+ it.skip('can be disabled', async () => {
29
+ const el = await fixture(html` <decidables-slider disabled>Slide</decidables-slider> `);
30
+
31
+ expect(el.shadowRoot).to.have.descendant('input').that.has.attribute('disabled');
32
+ expect(el.shadowRoot)
33
+ .to.have.descendant('decidables-spinner').that.has.attribute('disabled');
34
+ });
35
+
36
+ it('can have an upper limit', async () => {
37
+ const el = await fixture(html` <decidables-slider max="20">Slide</decidables-slider> `);
38
+
39
+ expect(el.shadowRoot).to.have.descendant('input').that.has.attribute('max', '20');
40
+ expect(el.shadowRoot).to.have.descendant('decidables-spinner').that.has.attribute('max', '20');
41
+ });
42
+
43
+ it('can have a lower limit', async () => {
44
+ const el = await fixture(html` <decidables-slider min="10">Slide</decidables-slider> `);
45
+
46
+ expect(el.shadowRoot).to.have.descendant('input').that.has.attribute('min', '10');
47
+ expect(el.shadowRoot).to.have.descendant('decidables-spinner').that.has.attribute('min', '10');
48
+ });
49
+
50
+ it('can have a step size', async () => {
51
+ const el = await fixture(html` <decidables-slider step="2">Slide</decidables-slider> `);
52
+
53
+ expect(el.shadowRoot).to.have.descendant('input').that.has.attribute('step', '2');
54
+ expect(el.shadowRoot).to.have.descendant('decidables-spinner').that.has.attribute('step', '2');
55
+ });
56
+
57
+ it('can have an initial value', async () => {
58
+ const el = await fixture(html` <decidables-slider value="17">Slide</decidables-slider> `);
59
+
60
+ expect(el).to.have.value(17);
61
+ expect(el.shadowRoot).to.have.descendant('input').that.has.value('17');
62
+ expect(el.shadowRoot).to.have.descendant('decidables-spinner').has.value(17);
63
+ });
64
+ });
@@ -0,0 +1,55 @@
1
+ import {expect, fixture, html} from '@open-wc/testing';
2
+
3
+ import '../src/spinner';
4
+
5
+ describe('decidables-spinner', () => {
6
+ it('has a shadowDom', async () => {
7
+ const el = await fixture(html` <decidables-spinner>Adjust</decidables-spinner> `);
8
+
9
+ expect(el).shadowDom.to.equal(`
10
+ <label>
11
+ <slot></slot>
12
+ <input type="number">
13
+ </label>
14
+ `);
15
+ });
16
+
17
+ it('has a lightDom', async () => {
18
+ const el = await fixture(html` <decidables-spinner>Adjust</decidables-spinner> `);
19
+
20
+ expect(el).lightDom.to.equal(`
21
+ Adjust
22
+ `);
23
+ });
24
+
25
+ it('can be disabled', async () => {
26
+ const el = await fixture(html` <decidables-spinner disabled>Adjust</decidables-spinner> `);
27
+
28
+ expect(el.shadowRoot).to.have.descendant('input').that.has.attribute('disabled');
29
+ });
30
+
31
+ it('can have an upper limit', async () => {
32
+ const el = await fixture(html` <decidables-spinner max="20">Adjust</decidables-spinner> `);
33
+
34
+ expect(el.shadowRoot).to.have.descendant('input').that.has.attribute('max', '20');
35
+ });
36
+
37
+ it('can have a lower limit', async () => {
38
+ const el = await fixture(html` <decidables-spinner min="10">Adjust</decidables-spinner> `);
39
+
40
+ expect(el.shadowRoot).to.have.descendant('input').that.has.attribute('min', '10');
41
+ });
42
+
43
+ it('can have a step size', async () => {
44
+ const el = await fixture(html` <decidables-spinner step="2">Adjust</decidables-spinner> `);
45
+
46
+ expect(el.shadowRoot).to.have.descendant('input').that.has.attribute('step', '2');
47
+ });
48
+
49
+ it('can have an initial value', async () => {
50
+ const el = await fixture(html` <decidables-spinner value="17">Slide</decidables-spinner> `);
51
+
52
+ expect(el).to.have.value(17);
53
+ expect(el.shadowRoot).to.have.descendant('input').that.has.value('17');
54
+ });
55
+ });
@@ -0,0 +1,71 @@
1
+ import {expect, fixture, html} from '@open-wc/testing';
2
+
3
+ import '../src/switch';
4
+
5
+ describe('decidables-switch', () => {
6
+ it('has a shadowDom', async () => {
7
+ const el = await fixture(html`
8
+ <decidables-switch>
9
+ <span>On</span>
10
+ <span slot="off-label">Off</span>
11
+ </decidables-switch>
12
+ `);
13
+
14
+ expect(el).shadowDom.to.equal(`
15
+ <input type="checkbox" id="decidables-1-checkbox">
16
+ <label for="decidables-1-checkbox">
17
+ <slot name="off-label"></slot>
18
+ </label>
19
+ <label for="decidables-1-checkbox">
20
+ <slot></slot>
21
+ </label>
22
+ `);
23
+ });
24
+
25
+ it('has a lightDom', async () => {
26
+ const el = await fixture(html`
27
+ <decidables-switch>
28
+ <span>On</span>
29
+ <span slot="off-label">Off</span>
30
+ </decidables-switch>
31
+ `);
32
+
33
+ expect(el).lightDom.to.equal(`
34
+ <span>On</span>
35
+ <span slot="off-label">Off</span>
36
+ `);
37
+ });
38
+
39
+ it('can be disabled', async () => {
40
+ const el = await fixture(html`
41
+ <decidables-switch disabled>
42
+ <span>On</span>
43
+ <span slot="off-label">Off</span>
44
+ </decidables-switch>
45
+ `);
46
+
47
+ expect(el.shadowRoot).to.have.descendant('input').that.has.attribute('disabled');
48
+ });
49
+
50
+ it('can be switched off', async () => {
51
+ const el = await fixture(html`
52
+ <decidables-switch>
53
+ <span>On</span>
54
+ <span slot="off-label">Off</span>
55
+ </decidables-switch>
56
+ `);
57
+
58
+ expect(el.shadowRoot).to.have.descendant('input').that.does.not.have.attribute('checked');
59
+ });
60
+
61
+ it('can be switched on', async () => {
62
+ const el = await fixture(html`
63
+ <decidables-switch checked>
64
+ <span>On</span>
65
+ <span slot="off-label">Off</span>
66
+ </decidables-switch>
67
+ `);
68
+
69
+ expect(el.shadowRoot).to.have.descendant('input').that.has.attribute('checked');
70
+ });
71
+ });
@@ -0,0 +1,62 @@
1
+ import {expect, fixture, html} from '@open-wc/testing';
2
+
3
+ import '../src/toggle-option';
4
+
5
+ describe('decidables-toggle-option', () => {
6
+ it('has a shadowDom', async () => {
7
+ const el = await fixture(html`
8
+ <decidables-toggle-option name="test" value="possibly">
9
+ Possibly
10
+ </decidables-toggle-option>
11
+ `);
12
+
13
+ expect(el).shadowDom.to.equal(`
14
+ <input type="radio" id="decidables-1-radio" name="test" value="possibly">
15
+ <label for="decidables-1-radio">
16
+ <slot></slot>
17
+ </label>
18
+ `);
19
+ });
20
+
21
+ it('has a lightDom', async () => {
22
+ const el = await fixture(html`
23
+ <decidables-toggle-option name="test" value="possibly">
24
+ Possibly
25
+ </decidables-toggle-option>
26
+ `);
27
+
28
+ expect(el).lightDom.to.equal(`
29
+ Possibly
30
+ `);
31
+ });
32
+
33
+ it.skip('can be disabled', async () => {
34
+ const el = await fixture(html`
35
+ <decidables-toggle-option name="test" value="possibly" disabled>
36
+ Possibly
37
+ </decidables-toggle-option>
38
+ `);
39
+
40
+ expect(el.shadowRoot).to.have.descendant('input').that.has.attribute('disabled');
41
+ });
42
+
43
+ it('can be toggled off', async () => {
44
+ const el = await fixture(html`
45
+ <decidables-toggle-option name="test" value="possibly">
46
+ Possibly
47
+ </decidables-toggle-option>
48
+ `);
49
+
50
+ expect(el.shadowRoot).to.have.descendant('input').that.has.property('checked', false);
51
+ });
52
+
53
+ it('can be toggled on', async () => {
54
+ const el = await fixture(html`
55
+ <decidables-toggle-option name="test" value="possibly" checked>
56
+ Possibly
57
+ </decidables-toggle-option>
58
+ `);
59
+
60
+ expect(el.shadowRoot).to.have.descendant('input').that.has.property('checked', true);
61
+ });
62
+ });
@@ -0,0 +1,98 @@
1
+ import {expect, fixture, html} from '@open-wc/testing';
2
+
3
+ import '../src/toggle';
4
+
5
+ describe('decidables-toggle', () => {
6
+ it('has a shadowDom', async () => {
7
+ const el = await fixture(html`
8
+ <decidables-toggle>
9
+ <span slot="label">Choose</span>
10
+ <decidables-toggle-option name="test" value="possibly">
11
+ Possibly
12
+ </decidables-toggle-option>
13
+ <decidables-toggle-option name="test" value="maybe">
14
+ Maybe
15
+ </decidables-toggle-option>
16
+ <decidables-toggle-option name="test" value="perhaps">
17
+ Perhaps
18
+ </decidables-toggle-option>
19
+ </decidables-toggle>
20
+ `);
21
+
22
+ expect(el).shadowDom.to.equal(`
23
+ <fieldset>
24
+ <legend><slot name="label"></slot></legend>
25
+ <slot></slot>
26
+ </fieldset>
27
+ `);
28
+ });
29
+
30
+ it('has a lightDom', async () => {
31
+ const el = await fixture(html`
32
+ <decidables-toggle>
33
+ <span slot="label">Choose</span>
34
+ <decidables-toggle-option name="test" value="possibly">
35
+ Possibly
36
+ </decidables-toggle-option>
37
+ <decidables-toggle-option name="test" value="maybe">
38
+ Maybe
39
+ </decidables-toggle-option>
40
+ <decidables-toggle-option name="test" value="perhaps">
41
+ Perhaps
42
+ </decidables-toggle-option>
43
+ </decidables-toggle>
44
+ `);
45
+
46
+ expect(el).lightDom.to.equal(`
47
+ <span slot="label">Choose</span>
48
+ <decidables-toggle-option name="test" value="possibly">
49
+ Possibly
50
+ </decidables-toggle-option>
51
+ <decidables-toggle-option name="test" value="maybe">
52
+ Maybe
53
+ </decidables-toggle-option>
54
+ <decidables-toggle-option name="test" value="perhaps">
55
+ Perhaps
56
+ </decidables-toggle-option>
57
+ `);
58
+ });
59
+
60
+ it('can be disabled', async () => {
61
+ const el = await fixture(html`
62
+ <decidables-toggle disabled>
63
+ <span slot="label">Choose</span>
64
+ <decidables-toggle-option name="test" value="possibly">
65
+ Possibly
66
+ </decidables-toggle-option>
67
+ <decidables-toggle-option name="test" value="maybe">
68
+ Maybe
69
+ </decidables-toggle-option>
70
+ <decidables-toggle-option name="test" value="perhaps">
71
+ Perhaps
72
+ </decidables-toggle-option>
73
+ </decidables-toggle>
74
+ `);
75
+
76
+ expect(el.shadowRoot).to.have.descendant('fieldset').that.has.attribute('disabled');
77
+ });
78
+
79
+ it('can have an option selected', async () => {
80
+ const el = await fixture(html`
81
+ <decidables-toggle disabled>
82
+ <span slot="label">Choose</span>
83
+ <decidables-toggle-option name="test" value="possibly">
84
+ Possibly
85
+ </decidables-toggle-option>
86
+ <decidables-toggle-option name="test" value="maybe" checked>
87
+ Maybe
88
+ </decidables-toggle-option>
89
+ <decidables-toggle-option name="test" value="perhaps">
90
+ Perhaps
91
+ </decidables-toggle-option>
92
+ </decidables-toggle>
93
+ `);
94
+
95
+ expect(el).to.have.descendants('decidables-toggle-option[checked]').with.length(1);
96
+ expect(el).to.have.descendants('decidables-toggle-option:not([checked])').with.length(2);
97
+ });
98
+ });