@scania/tegel 1.1.0 → 1.3.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.
Files changed (118) hide show
  1. package/README.md +3 -2
  2. package/dist/cjs/loader.cjs.js +1 -1
  3. package/dist/cjs/tds-breadcrumb.cjs.entry.js +1 -1
  4. package/dist/cjs/tds-breadcrumbs.cjs.entry.js +3 -1
  5. package/dist/cjs/tds-button.cjs.entry.js +1 -1
  6. package/dist/cjs/tds-checkbox.cjs.entry.js +16 -3
  7. package/dist/cjs/tds-dropdown-option.cjs.entry.js +5 -3
  8. package/dist/cjs/tds-dropdown.cjs.entry.js +13 -3
  9. package/dist/cjs/tds-footer-item.cjs.entry.js +1 -1
  10. package/dist/cjs/tds-slider.cjs.entry.js +60 -104
  11. package/dist/cjs/tds-step.cjs.entry.js +12 -7
  12. package/dist/cjs/tds-table-header.cjs.entry.js +3 -1
  13. package/dist/cjs/tds-toast.cjs.entry.js +4 -1
  14. package/dist/cjs/tegel.cjs.js +1 -1
  15. package/dist/collection/collection-manifest.json +3 -3
  16. package/dist/collection/components/accordion/test/basic/accordion.e2e.js +19 -0
  17. package/dist/collection/components/accordion/test/disabled/accordion.e2e.js +19 -0
  18. package/dist/collection/components/accordion/test/expanded/accordion.e2e.js +24 -0
  19. package/dist/collection/components/accordion/test/padding-reset/accordion.e2e.js +24 -0
  20. package/dist/collection/components/badge/test/basic/badge.e2e.js +10 -0
  21. package/dist/collection/components/badge/test/value/badge.e2e.js +11 -0
  22. package/dist/collection/components/banner/test/basic/banner.e2e.js +10 -0
  23. package/dist/collection/components/breadcrumbs/breadcrumb/breadcrumb.css +4 -3
  24. package/dist/collection/components/breadcrumbs/breadcrumbs.js +3 -1
  25. package/dist/collection/components/button/button.css +0 -4
  26. package/dist/collection/components/checkbox/checkbox.css +19 -0
  27. package/dist/collection/components/checkbox/checkbox.js +39 -5
  28. package/dist/collection/components/checkbox/checkbox.stories.js +25 -12
  29. package/dist/collection/components/datetime/datetime.stories.js +4 -4
  30. package/dist/collection/components/dropdown/dropdown-option/dropdown-option.css +26 -16
  31. package/dist/collection/components/dropdown/dropdown-option/dropdown-option.js +4 -2
  32. package/dist/collection/components/dropdown/dropdown.css +28 -0
  33. package/dist/collection/components/dropdown/dropdown.js +12 -2
  34. package/dist/collection/components/footer/footer-item/footer-item.css +4 -6
  35. package/dist/collection/components/slider/slider.js +61 -105
  36. package/dist/collection/components/stepper/step/step.js +13 -8
  37. package/dist/collection/components/table/table-component-multiselect.stories.js +18 -2
  38. package/dist/collection/components/table/table-header/table-header.js +43 -3
  39. package/dist/collection/components/text-field/text-field.stories.js +1 -1
  40. package/dist/collection/components/toast/toast.js +4 -1
  41. package/dist/collection/components/toast/toast.stories.js +10 -1
  42. package/dist/collection/stories/Installation/angular.stories.js +111 -0
  43. package/dist/collection/stories/Installation/javascript.stories.js +99 -0
  44. package/dist/collection/stories/Installation/react.stories.js +117 -0
  45. package/dist/collection/stories/announcements/announce-tegel.stories.js +5 -5
  46. package/dist/collection/stories/tegel.stories.js +7 -8
  47. package/dist/components/checkbox.js +20 -4
  48. package/dist/components/tds-breadcrumb.js +1 -1
  49. package/dist/components/tds-breadcrumbs.js +3 -1
  50. package/dist/components/tds-button.js +1 -1
  51. package/dist/components/tds-dropdown-option.js +5 -3
  52. package/dist/components/tds-dropdown.js +13 -3
  53. package/dist/components/tds-footer-item.js +1 -1
  54. package/dist/components/tds-slider.js +61 -105
  55. package/dist/components/tds-step.js +13 -8
  56. package/dist/components/tds-table-header.js +5 -1
  57. package/dist/components/tds-toast.js +4 -1
  58. package/dist/esm/loader.js +1 -1
  59. package/dist/esm/tds-breadcrumb.entry.js +1 -1
  60. package/dist/esm/tds-breadcrumbs.entry.js +3 -1
  61. package/dist/esm/tds-button.entry.js +1 -1
  62. package/dist/esm/tds-checkbox.entry.js +16 -3
  63. package/dist/esm/tds-dropdown-option.entry.js +5 -3
  64. package/dist/esm/tds-dropdown.entry.js +13 -3
  65. package/dist/esm/tds-footer-item.entry.js +1 -1
  66. package/dist/esm/tds-slider.entry.js +60 -104
  67. package/dist/esm/tds-step.entry.js +12 -7
  68. package/dist/esm/tds-table-header.entry.js +3 -1
  69. package/dist/esm/tds-toast.entry.js +4 -1
  70. package/dist/esm/tegel.js +1 -1
  71. package/dist/tegel/p-1aaf365d.entry.js +1 -0
  72. package/dist/tegel/p-24f22b04.entry.js +1 -0
  73. package/dist/tegel/p-3a930215.entry.js +1 -0
  74. package/dist/tegel/p-6361ae3a.entry.js +1 -0
  75. package/dist/tegel/{p-e3c5a663.entry.js → p-952a9830.entry.js} +1 -1
  76. package/dist/tegel/p-99327b6c.entry.js +1 -0
  77. package/dist/tegel/p-abe23e76.entry.js +1 -0
  78. package/dist/tegel/p-bf32d97c.entry.js +1 -0
  79. package/dist/tegel/p-c420b0a9.entry.js +1 -0
  80. package/dist/tegel/p-d6c1d080.entry.js +1 -0
  81. package/dist/tegel/p-fbd856ca.entry.js +1 -0
  82. package/dist/tegel/tegel.css +1 -1
  83. package/dist/tegel/tegel.esm.js +1 -1
  84. package/dist/types/components/breadcrumbs/breadcrumbs.d.ts +1 -1
  85. package/dist/types/components/checkbox/checkbox.d.ts +5 -0
  86. package/dist/types/components/checkbox/checkbox.stories.d.ts +13 -0
  87. package/dist/types/components/slider/slider.d.ts +19 -22
  88. package/dist/types/components/stepper/step/step.d.ts +1 -1
  89. package/dist/types/components/table/table-component-batch-actions.stories.d.ts +1 -1
  90. package/dist/types/components/table/table-component-multiselect.stories.d.ts +16 -0
  91. package/dist/types/components/table/table-header/table-header.d.ts +5 -1
  92. package/dist/types/components/toast/toast.stories.d.ts +8 -0
  93. package/dist/types/components.d.ts +27 -2
  94. package/dist/types/stories/Installation/angular.stories.d.ts +6 -0
  95. package/dist/types/stories/Installation/{installation.stories.d.ts → javascript.stories.d.ts} +1 -1
  96. package/dist/types/stories/Installation/react.stories.d.ts +6 -0
  97. package/dist/types/stories/formatHtmlPreview.d.ts +1 -1
  98. package/package.json +7 -7
  99. package/dist/collection/components/accordion/accordion.spec.js +0 -6
  100. package/dist/collection/components/divider/divider.spec.js +0 -28
  101. package/dist/collection/components/dropdown/test/dropdown.e2e.js +0 -32
  102. package/dist/collection/components/dropdown/test/dropdown.filter.spec.js +0 -49
  103. package/dist/collection/components/dropdown/test/dropdown.multiselect.e2e.js +0 -31
  104. package/dist/collection/components/dropdown/test/dropdown.multiselect.spec.js +0 -51
  105. package/dist/collection/components/dropdown/test/dropdown.spec.js +0 -51
  106. package/dist/collection/components/table/table.filtering.spec.js +0 -23
  107. package/dist/collection/components/table/table.spec.js +0 -16
  108. package/dist/collection/stories/Installation/installation.stories.js +0 -218
  109. package/dist/tegel/p-016d07b2.entry.js +0 -1
  110. package/dist/tegel/p-1a978a31.entry.js +0 -1
  111. package/dist/tegel/p-78f42968.entry.js +0 -1
  112. package/dist/tegel/p-80b501e3.entry.js +0 -1
  113. package/dist/tegel/p-8f1a037c.entry.js +0 -1
  114. package/dist/tegel/p-a0f3086c.entry.js +0 -1
  115. package/dist/tegel/p-be7119d3.entry.js +0 -1
  116. package/dist/tegel/p-c0b7acbb.entry.js +0 -1
  117. package/dist/tegel/p-e4db065d.entry.js +0 -1
  118. package/dist/tegel/p-eda7ecf6.entry.js +0 -1
@@ -205,6 +205,10 @@ export namespace Components {
205
205
  * Sets the Checkbox in a disabled state
206
206
  */
207
207
  "disabled": boolean;
208
+ /**
209
+ * Sets the Checkbox as indeterminate
210
+ */
211
+ "indeterminate": boolean;
208
212
  /**
209
213
  * Name for the Checkbox's input element.
210
214
  */
@@ -1089,9 +1093,17 @@ export namespace Components {
1089
1093
  }
1090
1094
  interface TdsTableHeader {
1091
1095
  /**
1092
- * Prop for controling the checked/unchecked state of the "all selected"-checkbox.
1096
+ * @deprecated Deprecated, use selected instead..
1093
1097
  */
1094
1098
  "allSelected": boolean;
1099
+ /**
1100
+ * Prop for controling the indeterminate state of the "All selected"-checkbox.
1101
+ */
1102
+ "indeterminate": boolean;
1103
+ /**
1104
+ * Prop for controling the checked/unchecked state of the "All selected"-checkbox.
1105
+ */
1106
+ "selected": boolean;
1095
1107
  }
1096
1108
  interface TdsTableToolbar {
1097
1109
  /**
@@ -2198,6 +2210,10 @@ declare namespace LocalJSX {
2198
2210
  * Sets the Checkbox in a disabled state
2199
2211
  */
2200
2212
  "disabled"?: boolean;
2213
+ /**
2214
+ * Sets the Checkbox as indeterminate
2215
+ */
2216
+ "indeterminate"?: boolean;
2201
2217
  /**
2202
2218
  * Name for the Checkbox's input element.
2203
2219
  */
@@ -2212,6 +2228,7 @@ declare namespace LocalJSX {
2212
2228
  "onTdsChange"?: (event: TdsCheckboxCustomEvent<{
2213
2229
  checkboxId: string;
2214
2230
  checked: boolean;
2231
+ indeterminate: boolean;
2215
2232
  value?: string;
2216
2233
  }>) => void;
2217
2234
  /**
@@ -3167,9 +3184,13 @@ declare namespace LocalJSX {
3167
3184
  }
3168
3185
  interface TdsTableHeader {
3169
3186
  /**
3170
- * Prop for controling the checked/unchecked state of the "all selected"-checkbox.
3187
+ * @deprecated Deprecated, use selected instead..
3171
3188
  */
3172
3189
  "allSelected"?: boolean;
3190
+ /**
3191
+ * Prop for controling the indeterminate state of the "All selected"-checkbox.
3192
+ */
3193
+ "indeterminate"?: boolean;
3173
3194
  /**
3174
3195
  * Event emitted when the status of the select all checkbox changes.
3175
3196
  */
@@ -3178,6 +3199,10 @@ declare namespace LocalJSX {
3178
3199
  checked: boolean;
3179
3200
  selectedRows: any[];
3180
3201
  }>) => void;
3202
+ /**
3203
+ * Prop for controling the checked/unchecked state of the "All selected"-checkbox.
3204
+ */
3205
+ "selected"?: boolean;
3181
3206
  }
3182
3207
  interface TdsTableToolbar {
3183
3208
  /**
@@ -0,0 +1,6 @@
1
+ import type { Meta } from '@storybook/html';
2
+ declare const meta: Meta;
3
+ export default meta;
4
+ export declare const Angular: {
5
+ render: () => string;
6
+ };
@@ -2,6 +2,6 @@ import type { Meta } from '@storybook/html';
2
2
  import '../../../.storybook/tegel.syntax.highlighter.css';
3
3
  declare const meta: Meta;
4
4
  export default meta;
5
- export declare const Installation: {
5
+ export declare const Javascript: {
6
6
  render: () => string;
7
7
  };
@@ -0,0 +1,6 @@
1
+ import type { Meta } from '@storybook/html';
2
+ declare const meta: Meta;
3
+ export default meta;
4
+ export declare const React: {
5
+ render: () => string;
6
+ };
@@ -1,2 +1,2 @@
1
- declare const formatHtmlPreview: (htmlStr: any) => string;
1
+ declare const formatHtmlPreview: (htmlStr: any) => any;
2
2
  export default formatHtmlPreview;
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@scania/tegel",
3
- "version": "1.1.0",
3
+ "version": "1.3.0",
4
4
  "description": "Tegel Design System",
5
+ "type": "module",
5
6
  "keywords": [
6
7
  "tegel",
7
8
  "scania",
@@ -34,12 +35,12 @@
34
35
  "scripts": {
35
36
  "build": "stencil build --docs",
36
37
  "start": "stencil build --dev --watch --serve",
37
- "test": "stencil test --spec --e2e",
38
+ "test": "docker run --rm --network host -v $(pwd):/work/ -w /work/ mcr.microsoft.com/playwright:v1.39.0-jammy /bin/bash -c 'npm install && npx playwright test && exit'",
39
+ "update-snapshots": "docker run --rm --network host -v $(pwd):/work/ -w /work/ mcr.microsoft.com/playwright:v1.39.0-jammy /bin/bash -c 'npm install && npx playwright test --update-snapshots && exit'",
38
40
  "test.watch": "stencil test --spec --e2e --watchAll",
39
41
  "generate": "stencil generate",
40
42
  "build-stencil:watch": "stencil build --docs-readme --watch",
41
43
  "commit": "npm run --prefix ../ commit",
42
- "tegel-release": "./tegel-release.sh",
43
44
  "build-storybook": "build-storybook --quiet",
44
45
  "build-stencil-storybook": "npm run build && npm run build-storybook",
45
46
  "start-storybook": "start-storybook -p 6006",
@@ -53,6 +54,7 @@
53
54
  },
54
55
  "devDependencies": {
55
56
  "@babel/core": "^7.19.1",
57
+ "@playwright/test": "^1.39.0",
56
58
  "@stencil/angular-output-target": "^0.8.2",
57
59
  "@stencil/react-output-target": "^0.5.3",
58
60
  "@stencil/sass": "^3.0.4",
@@ -66,14 +68,12 @@
66
68
  "@storybook/addons": "^6.5.15",
67
69
  "@storybook/builder-webpack4": "^6.5.16",
68
70
  "@storybook/html": "^6.5.15",
69
- "@types/jest": "^27.0.3",
70
71
  "addon-screen-reader": "^1.8.6",
71
72
  "babel-loader": "^8.2.5",
72
73
  "concurrently": "^8.0.1",
73
74
  "highlight.js": "^11.8.0",
74
- "jest": "^27.4.5",
75
- "jest-cli": "^27.4.5",
76
- "puppeteer": "^20.8.0",
75
+ "serve": "^14.2.1",
76
+ "stencil-playwright": "^0.3.0",
77
77
  "storybook-addon-designs": "^6.3.1",
78
78
  "storybook-dark-mode": "^3.0.0",
79
79
  "storybook-version": "^0.1.1"
@@ -1,6 +0,0 @@
1
- import { TdsAccordion } from "./accordion";
2
- describe('tds-accordion', () => {
3
- it('builds', () => {
4
- expect(new TdsAccordion()).toBeTruthy();
5
- });
6
- });
@@ -1,28 +0,0 @@
1
- import { newSpecPage } from "@stencil/core/testing";
2
- import { Divider } from "./divider";
3
- describe('tds-divider', () => {
4
- it('renders a horizontal divider by default', async () => {
5
- const page = await newSpecPage({
6
- components: [Divider],
7
- html: '<tds-divider></tds-divider>',
8
- supportsShadowDom: true,
9
- });
10
- const { root } = page;
11
- const divElement = root.shadowRoot.querySelector('div');
12
- expect(divElement).not.toBeNull();
13
- expect(root.getAttribute('role')).toBe('separator');
14
- expect(root.getAttribute('aria-orientation')).toBeFalsy();
15
- });
16
- it('renders a vertical divider when orientation is set to "vertical"', async () => {
17
- const page = await newSpecPage({
18
- components: [Divider],
19
- html: '<tds-divider orientation="vertical"></tds-divider>',
20
- supportsShadowDom: true,
21
- });
22
- const { root } = page;
23
- const divElement = root.shadowRoot.querySelector('div');
24
- expect(divElement).not.toBeNull();
25
- expect(root.getAttribute('role')).toBe('separator');
26
- expect(root.getAttribute('aria-orientation')).toBe('vertical');
27
- });
28
- });
@@ -1,32 +0,0 @@
1
- import { newE2EPage } from "@stencil/core/testing";
2
- describe('tds-dropdown', () => {
3
- it('should updated value when an option is clicked', async () => {
4
- const page = await newE2EPage();
5
- await page.setContent(`
6
- <tds-dropdown>
7
- <tds-dropdown-option value="option-1">
8
- Option 1
9
- </tds-dropdown-option>
10
- <tds-dropdown-option value="option-2">
11
- Option 2
12
- </tds-dropdown-option>
13
- <tds-dropdown-option value="option-3">
14
- Option 3
15
- </tds-dropdown-option>
16
- </tds-drodpown>
17
- `);
18
- const dropdown = await page.find('tds-dropdown');
19
- expect(dropdown).not.toBeNull();
20
- await dropdown.click();
21
- await page.waitForChanges();
22
- const firstDropdownOption = await page.find('tds-dropdown-option[value="option-1"]');
23
- await firstDropdownOption.click();
24
- await page.waitForChanges();
25
- expect(dropdown.getAttribute('value')).toBe('option-1');
26
- await dropdown.click();
27
- const secondDropdownOption = await page.find('tds-dropdown-option[value="option-2"]');
28
- await secondDropdownOption.click();
29
- await page.waitForChanges();
30
- expect(dropdown.getAttribute('value')).toBe('option-2');
31
- });
32
- });
@@ -1,49 +0,0 @@
1
- import { newSpecPage } from "@stencil/core/testing";
2
- import { h } from "@stencil/core";
3
- import { TdsDropdown } from "../dropdown";
4
- import { TdsDropdownOption } from "../dropdown-option/dropdown-option";
5
- const options = [
6
- {
7
- value: 'option-1',
8
- label: 'Option 1',
9
- disabled: false,
10
- },
11
- {
12
- value: 'option-2',
13
- label: 'Option 2',
14
- disabled: false,
15
- },
16
- {
17
- value: 'option-3',
18
- label: 'Option 3',
19
- disabled: true,
20
- },
21
- ];
22
- const getTemplate = (defaultValue) => ({
23
- components: [TdsDropdown, TdsDropdownOption],
24
- template: () => (h("tds-dropdown", { filter: true, defaultValue: defaultValue }, options.map((option) => (h("tds-dropdown-option", { value: option.value, disabled: option.disabled }, option.label))))),
25
- });
26
- describe('filter dropdown', () => {
27
- it('should render children correctly', async () => {
28
- const page = await newSpecPage(getTemplate());
29
- const children = await page.doc.querySelectorAll('tds-dropdown-option');
30
- expect(children.length).toBe(3);
31
- });
32
- it('should set defaultValue correctly', async () => {
33
- const page = await newSpecPage(getTemplate('option-1'));
34
- const dropdown = await page.doc.querySelector('tds-dropdown');
35
- expect(dropdown.getAttribute('value')).toBe('option-1');
36
- });
37
- it('should set value using setValue() correctly', async () => {
38
- const page = await newSpecPage(getTemplate('option-3'));
39
- const dropdown = await page.doc.querySelector('tds-dropdown');
40
- await dropdown.setValue('option-1');
41
- expect(dropdown.getAttribute('value')).toBe('option-1');
42
- });
43
- it('should remove value using removeValue() correctly', async () => {
44
- const page = await newSpecPage(getTemplate('option-3'));
45
- const dropdown = await page.doc.querySelector('tds-dropdown');
46
- await dropdown.removeValue('option-3');
47
- expect(dropdown.getAttribute('value')).toBe('null');
48
- });
49
- });
@@ -1,31 +0,0 @@
1
- import { newE2EPage } from "@stencil/core/testing";
2
- describe('tds-dropdown multiselect', () => {
3
- it('should updated value when an option is clicked', async () => {
4
- const page = await newE2EPage();
5
- await page.setContent(`
6
- <tds-dropdown multiselect>
7
- <tds-dropdown-option value="option-1">
8
- Option 1
9
- </tds-dropdown-option>
10
- <tds-dropdown-option value="option-2">
11
- Option 2
12
- </tds-dropdown-option>
13
- <tds-dropdown-option value="option-3">
14
- Option 3
15
- </tds-dropdown-option>
16
- </tds-drodpown>
17
- `);
18
- const dropdown = await page.find('tds-dropdown');
19
- expect(dropdown).not.toBeNull();
20
- await dropdown.click();
21
- await page.waitForChanges();
22
- const firstDropdownOption = await page.find('tds-dropdown-option[value="option-1"]');
23
- await firstDropdownOption.click();
24
- await page.waitForChanges();
25
- expect(dropdown.getAttribute('value')).toBe('option-1');
26
- const secondDropdownOption = await page.find('tds-dropdown-option[value="option-2"]');
27
- await secondDropdownOption.click();
28
- await page.waitForChanges();
29
- expect(dropdown.getAttribute('value')).toBe('option-1,option-2');
30
- });
31
- });
@@ -1,51 +0,0 @@
1
- import { newSpecPage } from "@stencil/core/testing";
2
- import { h } from "@stencil/core";
3
- import { TdsDropdown } from "../dropdown";
4
- import { TdsDropdownOption } from "../dropdown-option/dropdown-option";
5
- const options = [
6
- {
7
- value: 'option-1',
8
- label: 'Option 1',
9
- disabled: false,
10
- },
11
- {
12
- value: 'option-2',
13
- label: 'Option 2',
14
- disabled: false,
15
- },
16
- {
17
- value: 'option-3',
18
- label: 'Option 3',
19
- disabled: true,
20
- },
21
- ];
22
- const getTemplate = (defaultValue) => ({
23
- components: [TdsDropdown, TdsDropdownOption],
24
- template: () => (h("tds-dropdown", { multiselect: true, defaultValue: defaultValue }, options.map((option) => (h("tds-dropdown-option", { value: option.value, disabled: option.disabled }, option.label))))),
25
- });
26
- describe('multiselect dropdown', () => {
27
- it('should render children correctly', async () => {
28
- const page = await newSpecPage(getTemplate());
29
- const children = await page.doc.querySelectorAll('tds-dropdown-option');
30
- expect(children.length).toBe(3);
31
- });
32
- it('should set defaultValue correctly', async () => {
33
- const page = await newSpecPage(getTemplate('option-1,option-2'));
34
- const dropdown = await page.doc.querySelector('tds-dropdown');
35
- expect(dropdown.getAttribute('value')).toBe('option-1,option-2');
36
- });
37
- it('should set value using setValue() correctly', async () => {
38
- const page = await newSpecPage(getTemplate('option-1,option-2'));
39
- const dropdown = await page.doc.querySelector('tds-dropdown');
40
- await dropdown.setValue(['option-1', 'option-3']);
41
- expect(dropdown.getAttribute('value')).toBe('option-1,option-3');
42
- });
43
- it('should remove value using removeValue() correctly', async () => {
44
- const page = await newSpecPage(getTemplate('option-3,option-1'));
45
- const dropdown = await page.doc.querySelector('tds-dropdown');
46
- await dropdown.removeValue('option-3');
47
- expect(dropdown.getAttribute('value')).toBe('option-1');
48
- await dropdown.removeValue('option-1');
49
- expect(dropdown.getAttribute('value')).toBe('null');
50
- });
51
- });
@@ -1,51 +0,0 @@
1
- import { newSpecPage } from "@stencil/core/testing";
2
- import { h } from "@stencil/core";
3
- import { TdsDropdown } from "../dropdown";
4
- import { TdsDropdownOption } from "../dropdown-option/dropdown-option";
5
- const options = [
6
- {
7
- value: 'option-1',
8
- label: 'Option 1',
9
- disabled: false,
10
- },
11
- {
12
- value: 'option-2',
13
- label: 'Option 2',
14
- disabled: false,
15
- },
16
- {
17
- value: 'option-3',
18
- label: 'Option 3',
19
- disabled: true,
20
- },
21
- ];
22
- const getTemplate = (defaultValue) => ({
23
- components: [TdsDropdown, TdsDropdownOption],
24
- template: () => (h("tds-dropdown", { defaultValue: defaultValue }, options.map((option) => (h("tds-dropdown-option", { value: option.value, disabled: option.disabled }, option.label))))),
25
- });
26
- describe('singleselect dropdown', () => {
27
- it('should render children correctly', async () => {
28
- const page = await newSpecPage(getTemplate());
29
- const children = await page.doc.querySelectorAll('tds-dropdown-option');
30
- expect(children.length).toBe(3);
31
- });
32
- it('should set defaultValue correctly', async () => {
33
- const page = await newSpecPage(getTemplate('option-3'));
34
- const dropdown = await page.doc.querySelector('tds-dropdown');
35
- expect(dropdown.getAttribute('value')).toBe('option-3');
36
- expect(dropdown.getAttribute('value')).not.toBe('option-2');
37
- });
38
- it('should set value using setValue() correctly', async () => {
39
- const page = await newSpecPage(getTemplate('option-3'));
40
- const dropdown = await page.doc.querySelector('tds-dropdown');
41
- await dropdown.setValue('option-1');
42
- expect(dropdown.getAttribute('value')).toBe('option-1');
43
- expect(dropdown.getAttribute('value')).not.toBe('option-3');
44
- });
45
- it('should remove value using removeValue() correctly', async () => {
46
- const page = await newSpecPage(getTemplate('option-3'));
47
- const dropdown = await page.doc.querySelector('tds-dropdown');
48
- await dropdown.removeValue('option-3');
49
- expect(dropdown.getAttribute('value')).toBe('null');
50
- });
51
- });
@@ -1,23 +0,0 @@
1
- import { newSpecPage } from "@stencil/core/testing";
2
- import { h } from "@stencil/core";
3
- import { TdsTableBody } from "./table-body/table-body";
4
- import { TdsTableHeaderRow } from "./table-header/table-header";
5
- import { TdsTable } from "./table/table";
6
- import { TdsTableHeaderCell } from "./table-header-cell/table-header-cell";
7
- import { TdsTableToolbar } from "./table-toolbar/table-toolbar";
8
- describe('tds-table filtering', () => {
9
- it('should render cells from enable-dummy-data prop', async () => {
10
- const mismatchingCellSpy = jest.fn();
11
- const matchingCellSpy = jest.fn();
12
- const page = await newSpecPage({
13
- components: [TdsTable, TdsTableToolbar, TdsTableHeaderRow, TdsTableHeaderCell, TdsTableBody],
14
- template: () => (h("tds-table", { "table-id": "unique-test-id" }, h("tds-table-toolbar", { "table-title": "Filter me", filter: true }), h("tds-table-header", null, h("tds-header-cell", { "cell-key": "truck" }), h("tds-header-cell", { "cell-key": "driver" }), h("tds-header-cell", { "cell-key": "country" }), h("tds-header-cell", { "cell-key": "mileage" })), h("tds-table-body", null, h("tds-table-body-row", null, h("tds-body-cell", { "cell-key": "truck", "cell-value": "L-series" }), h("tds-body-cell", { "cell-key": "driver", "cell-value": "Sonya Bruce", onClick: (e) => matchingCellSpy(e) }), h("tds-body-cell", { "cell-key": "country", "cell-value": "Brazil" }), h("tds-body-cell", { "cell-key": "mileage", "cell-value": "123987" })), h("tds-table-body-row", null, h("tds-body-cell", { "cell-key": "truck", "cell-value": "P-series" }), h("tds-body-cell", { "cell-key": "driver", "cell-value": "Guerra Bowman" }), h("tds-body-cell", { "cell-key": "country", "cell-value": "Sweden" }), h("tds-body-cell", { "cell-key": "mileage", "cell-value": "2000852" })), h("tds-table-body-row", null, h("tds-body-cell", { "cell-key": "truck", "cell-value": "G-series" }), h("tds-body-cell", { "cell-key": "driver", "cell-value": "Ferrell Wallace", onClick: (e) => mismatchingCellSpy(e) }), h("tds-body-cell", { "cell-key": "country", "cell-value": "Germany" }), h("tds-body-cell", { "cell-key": "mileage", "cell-value": "564" })), h("tds-table-body-row", null, h("tds-body-cell", { "cell-key": "truck", "cell-value": "R-series" }), h("tds-body-cell", { "cell-key": "driver", "cell-value": "Cox Burris" }), h("tds-body-cell", { "cell-key": "country", "cell-value": "Spain" }), h("tds-body-cell", { "cell-key": "mileage", "cell-value": "1789357" })), h("tds-table-body-row", null, h("tds-body-cell", { "cell-key": "truck", "cell-value": "S-series" }), h("tds-body-cell", { "cell-key": "driver", "cell-value": "Montgomery Cervantes" }), h("tds-body-cell", { "cell-key": "country", "cell-value": "Croatia" }), h("tds-body-cell", { "cell-key": "mileage", "cell-value": "65" })), h("tds-table-body-row", null, h("tds-body-cell", { "cell-key": "truck", "cell-value": "L-series" }), h("tds-body-cell", { "cell-key": "driver", "cell-value": "Sheryl Nielsen" }), h("tds-body-cell", { "cell-key": "country", "cell-value": "Greece" }), h("tds-body-cell", { "cell-key": "mileage", "cell-value": "365784" })), h("tds-table-body-row", null, h("tds-body-cell", { "cell-key": "truck", "cell-value": "G-series" }), h("tds-body-cell", { "cell-key": "driver", "cell-value": "Benton Gomez" }), h("tds-body-cell", { "cell-key": "country", "cell-value": "France" }), h("tds-body-cell", { "cell-key": "mileage", "cell-value": "80957" }))))),
15
- });
16
- const toolbarEl = await page.doc.querySelector('tds-table-toolbar');
17
- const inputEl = toolbarEl.shadowRoot.querySelector('input');
18
- inputEl.value = 'sonya';
19
- inputEl.dispatchEvent(new Event('keydown'));
20
- inputEl.dispatchEvent(new Event('input'));
21
- inputEl.dispatchEvent(new Event('keyup'));
22
- });
23
- });
@@ -1,16 +0,0 @@
1
- import { newSpecPage } from "@stencil/core/testing";
2
- import { h } from "@stencil/core";
3
- import { TdsTableBody } from "./table-body/table-body";
4
- import { TdsTableHeaderRow } from "./table-header/table-header";
5
- import { TdsTable } from "./table/table";
6
- import { TdsTableHeaderCell } from "./table-header-cell/table-header-cell";
7
- describe('tds-table', () => {
8
- it('should render cells from body-data prop', async () => {
9
- const page = await newSpecPage({
10
- components: [TdsTable, TdsTableHeaderRow, TdsTableHeaderCell, TdsTableBody],
11
- template: () => (h("tds-table", { "table-id": "unique-test-id" }, h("tds-table-header", null, h("tds-header-cell", { "cell-key": "truck" }), h("tds-header-cell", { "cell-key": "driver" }), h("tds-header-cell", { "cell-key": "country" }), h("tds-header-cell", { "cell-key": "mileage" })), h("tds-table-body", null, h("tds-table-body-row", null, h("tds-body-cell", { "cell-key": "truck", "cell-value": "L-series" }), h("tds-body-cell", { "cell-key": "driver", "cell-value": "Sonya Bruce" }), h("tds-body-cell", { "cell-key": "country", "cell-value": "Brazil" }), h("tds-body-cell", { "cell-key": "mileage", "cell-value": "123987" })), h("tds-table-body-row", null, h("tds-body-cell", { "cell-key": "truck", "cell-value": "P-series" }), h("tds-body-cell", { "cell-key": "driver", "cell-value": "Guerra Bowman" }), h("tds-body-cell", { "cell-key": "country", "cell-value": "Sweden" }), h("tds-body-cell", { "cell-key": "mileage", "cell-value": "2000852" })), h("tds-table-body-row", null, h("tds-body-cell", { "cell-key": "truck", "cell-value": "G-series" }), h("tds-body-cell", { "cell-key": "driver", "cell-value": "Ferrell Wallace" }), h("tds-body-cell", { "cell-key": "country", "cell-value": "Germany" }), h("tds-body-cell", { "cell-key": "mileage", "cell-value": "564" })), h("tds-table-body-row", null, h("tds-body-cell", { "cell-key": "truck", "cell-value": "R-series" }), h("tds-body-cell", { "cell-key": "driver", "cell-value": "Cox Burris" }), h("tds-body-cell", { "cell-key": "country", "cell-value": "Spain" }), h("tds-body-cell", { "cell-key": "mileage", "cell-value": "1789357" })), h("tds-table-body-row", null, h("tds-body-cell", { "cell-key": "truck", "cell-value": "S-series" }), h("tds-body-cell", { "cell-key": "driver", "cell-value": "Montgomery Cervantes" }), h("tds-body-cell", { "cell-key": "country", "cell-value": "Croatia" }), h("tds-body-cell", { "cell-key": "mileage", "cell-value": "65" })), h("tds-table-body-row", null, h("tds-body-cell", { "cell-key": "truck", "cell-value": "L-series" }), h("tds-body-cell", { "cell-key": "driver", "cell-value": "Sheryl Nielsen" }), h("tds-body-cell", { "cell-key": "country", "cell-value": "Greece" }), h("tds-body-cell", { "cell-key": "mileage", "cell-value": "365784" })), h("tds-table-body-row", null, h("tds-body-cell", { "cell-key": "truck", "cell-value": "G-series" }), h("tds-body-cell", { "cell-key": "driver", "cell-value": "Benton Gomez" }), h("tds-body-cell", { "cell-key": "country", "cell-value": "France" }), h("tds-body-cell", { "cell-key": "mileage", "cell-value": "80957" }))))),
12
- });
13
- const cells = await page.doc.querySelectorAll('tds-body-cell');
14
- expect(cells.length).toBe(4 * 7);
15
- });
16
- });