@oslokommune/punkt-elements 13.5.4 → 13.5.6
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/CHANGELOG.md +34 -0
- package/dist/pkt-index.cjs +1 -1
- package/dist/pkt-index.js +1 -1
- package/dist/pkt-select.cjs +1 -1
- package/dist/pkt-select.js +1 -1
- package/dist/{select-Dkl0KhGW.cjs → select-CD6Zn8YH.cjs} +12 -12
- package/dist/{select-CJS_CIKv.js → select-dcaJHvmR.js} +20 -20
- package/package.json +2 -2
- package/src/components/progressbar/progressbar.test.ts +195 -0
- package/src/components/radiobutton/radiobutton.test.ts +272 -0
- package/src/components/select/select.test.ts +227 -0
- package/src/components/select/select.ts +23 -12
- package/src/components/tag/tag.test.ts +211 -0
- package/src/components/textarea/textarea.test.ts +289 -0
- package/src/components/textinput/textinput.test.ts +421 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,40 @@ og skriver commits ca etter [Conventional Commits](https://conventionalcommits.o
|
|
|
5
5
|
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
+
## [13.5.6](https://github.com/oslokommune/punkt/compare/13.5.5...13.5.6) (2025-09-09)
|
|
9
|
+
|
|
10
|
+
### ⚠ BREAKING CHANGES
|
|
11
|
+
Ingen
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
Ingen
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
Ingen
|
|
18
|
+
|
|
19
|
+
### Chores
|
|
20
|
+
Ingen
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## [13.5.5](https://github.com/oslokommune/punkt/compare/13.5.4...13.5.5) (2025-09-09)
|
|
26
|
+
|
|
27
|
+
### ⚠ BREAKING CHANGES
|
|
28
|
+
Ingen
|
|
29
|
+
|
|
30
|
+
### Features
|
|
31
|
+
Ingen
|
|
32
|
+
|
|
33
|
+
### Bug Fixes
|
|
34
|
+
Ingen
|
|
35
|
+
|
|
36
|
+
### Chores
|
|
37
|
+
Ingen
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
|
|
8
42
|
## [13.5.4](https://github.com/oslokommune/punkt/compare/13.5.3...13.5.4) (2025-09-09)
|
|
9
43
|
|
|
10
44
|
### ⚠ BREAKING CHANGES
|
package/dist/pkt-index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("./alert-7rUOhlNi.cjs"),l=require("./accordionitem-Csh7iSVG.cjs"),d=require("./backlink-JbBNi3qg.cjs"),b=require("./button-B8rdtaHB.cjs"),k=require("./calendar-32W9p9uc.cjs"),m=require("./card-DBlFf1ry.cjs"),g=require("./combobox-DjO0RMUB.cjs"),h=require("./consent-hYeFWNFr.cjs"),f=require("./checkbox-Gn7Wtk9h.cjs"),t=require("./element-6DBpyGQm.cjs"),y=require("./pkt-slot-controller-BzddBp7z.cjs"),s=require("./ref-iJtiv3o2.cjs"),O=require("./class-map-BBG2gMX4.cjs"),j=require("./datepicker-CmTrG5GE.cjs"),q=require("./helptext-CzQX6YVE.cjs"),x=require("./heading-CNycsyMj.cjs"),C=require("./icon-B_ryAy4Q.cjs"),v=require("./input-wrapper-CZ-a00V7.cjs"),S=require("./link-Cjl0xwSq.cjs"),$=require("./linkcard-DqIvb54H.cjs"),L=require("./loader-DNidjwH-.cjs"),_=require("./messagebox-CjPtPPrW.cjs"),A=require("./modal-CRtxhCaP.cjs"),B=require("./progressbar-DhMBXkww.cjs"),p=require("./radiobutton-CdT6v1oq.cjs"),T=require("./tag-Bbs0U_Au.cjs"),I=require("./textarea-CPXsMFUq.cjs"),M=require("./textinput-aNI5kibM.cjs"),R=require("./select-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("./alert-7rUOhlNi.cjs"),l=require("./accordionitem-Csh7iSVG.cjs"),d=require("./backlink-JbBNi3qg.cjs"),b=require("./button-B8rdtaHB.cjs"),k=require("./calendar-32W9p9uc.cjs"),m=require("./card-DBlFf1ry.cjs"),g=require("./combobox-DjO0RMUB.cjs"),h=require("./consent-hYeFWNFr.cjs"),f=require("./checkbox-Gn7Wtk9h.cjs"),t=require("./element-6DBpyGQm.cjs"),y=require("./pkt-slot-controller-BzddBp7z.cjs"),s=require("./ref-iJtiv3o2.cjs"),O=require("./class-map-BBG2gMX4.cjs"),j=require("./datepicker-CmTrG5GE.cjs"),q=require("./helptext-CzQX6YVE.cjs"),x=require("./heading-CNycsyMj.cjs"),C=require("./icon-B_ryAy4Q.cjs"),v=require("./input-wrapper-CZ-a00V7.cjs"),S=require("./link-Cjl0xwSq.cjs"),$=require("./linkcard-DqIvb54H.cjs"),L=require("./loader-DNidjwH-.cjs"),_=require("./messagebox-CjPtPPrW.cjs"),A=require("./modal-CRtxhCaP.cjs"),B=require("./progressbar-DhMBXkww.cjs"),p=require("./radiobutton-CdT6v1oq.cjs"),T=require("./tag-Bbs0U_Au.cjs"),I=require("./textarea-CPXsMFUq.cjs"),M=require("./textinput-aNI5kibM.cjs"),R=require("./select-CD6Zn8YH.cjs");var H=Object.defineProperty,w=Object.getOwnPropertyDescriptor,o=(a,e,r,i)=>{for(var n=i>1?void 0:i?w(e,r):e,u=a.length-1,c;u>=0;u--)(c=a[u])&&(n=(i?c(e,r,n):c(n))||n);return i&&n&&H(e,r,n),n};exports.PktComponent=class extends t.PktElement{constructor(){super(),this.string="",this.strings=[],this.darkmode=!1,this._list=[],this.defaultSlot=s.e(),this.namedSlot=s.e(),this.slotController=new y.PktSlotController(this,this.defaultSlot,this.namedSlot)}connectedCallback(){this.strings.length&&this.strings.forEach(e=>{this._list.push(e.toUpperCase())}),super.connectedCallback()}render(){const e={"pkt-component":!0,"pkt-component--has-list":this.strings.length>0,"pkt-darkmode":this.darkmode};return t.x`
|
|
2
2
|
<div class="${O.e(e)}">
|
|
3
3
|
<h1 class="pkt-txt-28">${this.string}</h1>
|
|
4
4
|
|
package/dist/pkt-index.js
CHANGED
|
@@ -27,7 +27,7 @@ import { P as ht, P as ct } from "./radiobutton-CWxiIVfA.js";
|
|
|
27
27
|
import { P as ut } from "./tag-DyXzTY68.js";
|
|
28
28
|
import { P as vt } from "./textarea-BZL8Mkm0.js";
|
|
29
29
|
import { P as bt } from "./textinput-DjPhmmkB.js";
|
|
30
|
-
import { P as $t } from "./select-
|
|
30
|
+
import { P as $t } from "./select-dcaJHvmR.js";
|
|
31
31
|
var g = Object.defineProperty, v = Object.getOwnPropertyDescriptor, s = (t, e, i, a) => {
|
|
32
32
|
for (var r = a > 1 ? void 0 : a ? v(e, i) : e, p = t.length - 1, l; p >= 0; p--)
|
|
33
33
|
(l = t[p]) && (r = (a ? l(e, i, r) : l(r)) || r);
|
package/dist/pkt-select.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./select-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./select-CD6Zn8YH.cjs"),t=e.PktSelect;Object.defineProperty(exports,"PktSelect",{enumerable:!0,get:()=>e.PktSelect});exports.default=t;
|
package/dist/pkt-select.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const h=require("./element-6DBpyGQm.cjs"),p=require("./state-DPobt-Yz.cjs"),r=require("./ref-iJtiv3o2.cjs"),l=require("./if-defined-Cni-RHLS.cjs"),d=require("./input-element-C4xJoM-X.cjs"),c=require("./pkt-options-controller-CiuBG6Lt.cjs"),v=require("./pkt-slot-controller-BzddBp7z.cjs");require("./input-wrapper-CZ-a00V7.cjs");var f=Object.defineProperty,b=Object.getOwnPropertyDescriptor,a=(u,t,e,s)=>{for(var i=s>1?void 0:s?b(t,e):t,o=u.length-1,n;o>=0;o--)(n=u[o])&&(i=(s?n(t,e,i):n(i))||i);return s&&i&&f(t,e,i),i};exports.PktSelect=class extends d.PktInputElement{constructor(){super(),this.inputRef=r.e(),this.helptextSlot=r.e(),this.options=[],this.value="",this._options=[],this.selectedIndex=-1,this.selectedOptions=void 0,this.optionsController=new c.PktOptionsSlotController(this),this.slotController=new v.PktSlotController(this,this.helptextSlot),this.slotController.skipOptions=!0}connectedCallback(){super.connectedCallback();const t=this.options.length>0,e=this.optionsController.nodes.length&&this.optionsController.nodes.length>0;!t&&e?this.optionsController.nodes.forEach(s=>{const i={value:s.hasAttribute("value")?s.getAttribute("value")??"":s.textContent??"",label:s.textContent||s.getAttribute("value")||"",disabled:s.hasAttribute("disabled"),selected:s.hasAttribute("selected"),hidden:s.hasAttribute("data-hidden")};s.getAttribute("selected")&&!this.value&&(this.value=i.value),this._options.push(i)}):(this._options=this.options,this._options.forEach(s=>{s.selected&&!this.value&&(this.value=s.value)}))}add(t,e){var s,i,o;(s=this.inputRef.value)==null||s.add(t,e),this._options.push({value:t.value||t.text,label:t.text||t.value,selected:t.selected,disabled:t.disabled}),t.selected&&(this.value=t.value||t.text,this.selectedIndex=this.returnNumberOrNull((i=this.inputRef.value)==null?void 0:i.selectedIndex),this.selectedOptions=(o=this.inputRef.value)==null?void 0:o.selectedOptions),this.requestUpdate()}remove(t){var e,s;typeof t=="number"&&(this.selectedIndex===t&&(this.value=((e=this._options[0])==null?void 0:e.value)||""),(s=this.inputRef.value)==null||s.remove(t))}item(t){var e;return(e=this.inputRef.value)==null?void 0:e.item(t)}namedItem(t){var e;return(e=this.inputRef.value)==null?void 0:e.namedItem(t)}showPicker(){var t;(t=this.inputRef.value)==null||t.showPicker()}attributeChangedCallback(t,e,s){var i,o;t==="options"&&(this._options=s?JSON.parse(s):[]),t==="value"&&this.value!==e&&(this.selectedIndex=this.touched?this.returnNumberOrNull((i=this.inputRef.value)==null?void 0:i.selectedIndex):this.options.findIndex(n=>n.value===s),this.selectedOptions=(o=this.inputRef.value)==null?void 0:o.selectedOptions,this.valueChanged(s,e)),super.attributeChangedCallback(t,e,s)}update(t){var e,s;super.update(t),t.has("options")&&(this._options=this.options,this.requestUpdate("_options"),!this.value&&this._options.length>0&&(this.value=this._options[0].value,this.selectedIndex=0)),t.has("value")&&this.value!==t.get("value")&&(this.selectedIndex=this.touched?this.returnNumberOrNull((e=this.inputRef.value)==null?void 0:e.selectedIndex):this.options.findIndex(i=>i.value===this.value),this.selectedOptions=(s=this.inputRef.value)==null?void 0:s.selectedOptions,this.valueChanged(this.value,t.get("value"))),t.has("id")&&!this.name&&this.id&&(this.name=this.id)}firstUpdated(t){var e;super.firstUpdated(t),this.options.length&&(this._options=this.options),!this.value&&this._options.length>0?(this.value=this._options[0].value,this.selectedIndex=0):this.selectedIndex=this._options.findIndex(s=>s.value===this.value),this.selectedOptions=(e=this.inputRef.value)==null?void 0:e.selectedOptions}render(){const t=`pkt-input ${this.fullwidth?"pkt-input--fullwidth":""}`;return h.x`
|
|
2
2
|
<pkt-input-wrapper
|
|
3
3
|
?counter=${this.counter}
|
|
4
4
|
?disabled=${this.disabled}
|
|
@@ -33,17 +33,17 @@
|
|
|
33
33
|
@input=${e=>{this.onInput(),e.stopImmediatePropagation()}}
|
|
34
34
|
@focus=${e=>{this.onFocus(),e.stopImmediatePropagation()}}
|
|
35
35
|
@blur=${e=>{this.onBlur(),e.stopImmediatePropagation()}}
|
|
36
|
-
${
|
|
36
|
+
${r.n(this.inputRef)}
|
|
37
37
|
>
|
|
38
|
-
${this._options.length>0
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
38
|
+
${this._options.length>0?this._options.map(e=>h.x`<option
|
|
39
|
+
value=${e.value}
|
|
40
|
+
?selected=${this.value==e.value||e.selected}
|
|
41
|
+
?disabled=${e.disabled}
|
|
42
|
+
?hidden=${e.hidden}
|
|
43
|
+
>
|
|
44
|
+
${e.label}
|
|
45
|
+
</option>`):""}
|
|
46
46
|
</select>
|
|
47
|
-
<div class="pkt-contents" ${
|
|
47
|
+
<div class="pkt-contents" ${r.n(this.helptextSlot)} name="helptext" slot="helptext"></div>
|
|
48
48
|
</pkt-input-wrapper>
|
|
49
|
-
`}returnNumberOrNull(t){return t==null||isNaN(t)?null:t}};a([
|
|
49
|
+
`}returnNumberOrNull(t){return t==null||isNaN(t)?null:t}};a([h.n({type:Array})],exports.PktSelect.prototype,"options",2);a([h.n({type:String})],exports.PktSelect.prototype,"value",2);a([p.r()],exports.PktSelect.prototype,"_options",2);exports.PktSelect=a([h.t("pkt-select")],exports.PktSelect);
|
|
@@ -7,11 +7,11 @@ import { P as $ } from "./pkt-options-controller-CZO1nxZ8.js";
|
|
|
7
7
|
import { P as x } from "./pkt-slot-controller-BPGj-LC5.js";
|
|
8
8
|
import "./input-wrapper-Dr__Sxql.js";
|
|
9
9
|
var m = Object.defineProperty, g = Object.getOwnPropertyDescriptor, n = (t, e, s, i) => {
|
|
10
|
-
for (var l = i > 1 ? void 0 : i ? g(e, s) : e,
|
|
11
|
-
(r = t[
|
|
10
|
+
for (var l = i > 1 ? void 0 : i ? g(e, s) : e, h = t.length - 1, r; h >= 0; h--)
|
|
11
|
+
(r = t[h]) && (l = (i ? r(e, s, l) : r(l)) || l);
|
|
12
12
|
return i && l && m(e, s, l), l;
|
|
13
13
|
};
|
|
14
|
-
let
|
|
14
|
+
let a = class extends b {
|
|
15
15
|
constructor() {
|
|
16
16
|
super(), this.inputRef = u(), this.helptextSlot = u(), this.options = [], this.value = "", this._options = [], this.selectedIndex = -1, this.selectedOptions = void 0, this.optionsController = new $(this), this.slotController = new x(this, this.helptextSlot), this.slotController.skipOptions = !0;
|
|
17
17
|
}
|
|
@@ -64,11 +64,11 @@ let h = class extends b {
|
|
|
64
64
|
}
|
|
65
65
|
attributeChangedCallback(t, e, s) {
|
|
66
66
|
var i, l;
|
|
67
|
-
t === "options" && (this._options = s ? JSON.parse(s) : []), t === "value" && this.value !== e && (this.selectedIndex = this.touched ? this.returnNumberOrNull((i = this.inputRef.value) == null ? void 0 : i.selectedIndex) : this.options.findIndex((
|
|
67
|
+
t === "options" && (this._options = s ? JSON.parse(s) : []), t === "value" && this.value !== e && (this.selectedIndex = this.touched ? this.returnNumberOrNull((i = this.inputRef.value) == null ? void 0 : i.selectedIndex) : this.options.findIndex((h) => h.value === s), this.selectedOptions = (l = this.inputRef.value) == null ? void 0 : l.selectedOptions, this.valueChanged(s, e)), super.attributeChangedCallback(t, e, s);
|
|
68
68
|
}
|
|
69
69
|
update(t) {
|
|
70
70
|
var e, s;
|
|
71
|
-
super.update(t), t.has("value") && this.value !== t.get("value") && (this.selectedIndex = this.touched ? this.returnNumberOrNull((e = this.inputRef.value) == null ? void 0 : e.selectedIndex) : this.options.findIndex((i) => i.value === this.value), this.selectedOptions = (s = this.inputRef.value) == null ? void 0 : s.selectedOptions, this.valueChanged(this.value, t.get("value"))), t.has("id") && !this.name && this.id && (this.name = this.id);
|
|
71
|
+
super.update(t), t.has("options") && (this._options = this.options, this.requestUpdate("_options"), !this.value && this._options.length > 0 && (this.value = this._options[0].value, this.selectedIndex = 0)), t.has("value") && this.value !== t.get("value") && (this.selectedIndex = this.touched ? this.returnNumberOrNull((e = this.inputRef.value) == null ? void 0 : e.selectedIndex) : this.options.findIndex((i) => i.value === this.value), this.selectedOptions = (s = this.inputRef.value) == null ? void 0 : s.selectedOptions, this.valueChanged(this.value, t.get("value"))), t.has("id") && !this.name && this.id && (this.name = this.id);
|
|
72
72
|
}
|
|
73
73
|
firstUpdated(t) {
|
|
74
74
|
var e;
|
|
@@ -121,16 +121,16 @@ let h = class extends b {
|
|
|
121
121
|
}}
|
|
122
122
|
${d(this.inputRef)}
|
|
123
123
|
>
|
|
124
|
-
${this._options.length > 0
|
|
124
|
+
${this._options.length > 0 ? this._options.map(
|
|
125
125
|
(e) => p`<option
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
)}
|
|
126
|
+
value=${e.value}
|
|
127
|
+
?selected=${this.value == e.value || e.selected}
|
|
128
|
+
?disabled=${e.disabled}
|
|
129
|
+
?hidden=${e.hidden}
|
|
130
|
+
>
|
|
131
|
+
${e.label}
|
|
132
|
+
</option>`
|
|
133
|
+
) : ""}
|
|
134
134
|
</select>
|
|
135
135
|
<div class="pkt-contents" ${d(this.helptextSlot)} name="helptext" slot="helptext"></div>
|
|
136
136
|
</pkt-input-wrapper>
|
|
@@ -142,16 +142,16 @@ let h = class extends b {
|
|
|
142
142
|
};
|
|
143
143
|
n([
|
|
144
144
|
c({ type: Array })
|
|
145
|
-
],
|
|
145
|
+
], a.prototype, "options", 2);
|
|
146
146
|
n([
|
|
147
147
|
c({ type: String })
|
|
148
|
-
],
|
|
148
|
+
], a.prototype, "value", 2);
|
|
149
149
|
n([
|
|
150
150
|
f()
|
|
151
|
-
],
|
|
152
|
-
|
|
151
|
+
], a.prototype, "_options", 2);
|
|
152
|
+
a = n([
|
|
153
153
|
v("pkt-select")
|
|
154
|
-
],
|
|
154
|
+
], a);
|
|
155
155
|
export {
|
|
156
|
-
|
|
156
|
+
a as P
|
|
157
157
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oslokommune/punkt-elements",
|
|
3
|
-
"version": "13.5.
|
|
3
|
+
"version": "13.5.6",
|
|
4
4
|
"description": "Komponentbiblioteket til Punkt, et designsystem laget av Oslo Origo",
|
|
5
5
|
"homepage": "https://punkt.oslo.kommune.no",
|
|
6
6
|
"author": "Team Designsystem, Oslo Origo",
|
|
@@ -73,5 +73,5 @@
|
|
|
73
73
|
"url": "https://github.com/oslokommune/punkt/issues"
|
|
74
74
|
},
|
|
75
75
|
"license": "MIT",
|
|
76
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "5f0019a262ea4b9086590f7b6d572f5a39142f31"
|
|
77
77
|
}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import '@testing-library/jest-dom'
|
|
2
|
+
import { axe, toHaveNoViolations } from 'jest-axe'
|
|
3
|
+
import { createElementTest, BaseTestConfig } from '../../tests/test-framework'
|
|
4
|
+
import { CustomElementFor } from '../../tests/component-registry'
|
|
5
|
+
import { type IPktProgressbar } from './progressbar'
|
|
6
|
+
import './progressbar'
|
|
7
|
+
|
|
8
|
+
export interface ProgressbarTestConfig extends Partial<IPktProgressbar>, BaseTestConfig {}
|
|
9
|
+
|
|
10
|
+
export const createProgressbarTest = async (config: ProgressbarTestConfig = {}) => {
|
|
11
|
+
const { container, element } = await createElementTest<
|
|
12
|
+
CustomElementFor<'pkt-progressbar'>,
|
|
13
|
+
ProgressbarTestConfig
|
|
14
|
+
>('pkt-progressbar', config)
|
|
15
|
+
|
|
16
|
+
return {
|
|
17
|
+
container,
|
|
18
|
+
progressbar: element,
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
expect.extend(toHaveNoViolations)
|
|
23
|
+
|
|
24
|
+
afterEach(() => {
|
|
25
|
+
document.body.innerHTML = ''
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
describe('PktProgressbar', () => {
|
|
29
|
+
describe('Rendering and basic functionality', () => {
|
|
30
|
+
test('renders without errors', async () => {
|
|
31
|
+
const { progressbar } = await createProgressbarTest()
|
|
32
|
+
|
|
33
|
+
expect(progressbar).toBeInTheDocument()
|
|
34
|
+
expect(progressbar).toBeTruthy()
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
test('renders with progress value', async () => {
|
|
38
|
+
const { progressbar } = await createProgressbarTest({ valueCurrent: 50 })
|
|
39
|
+
|
|
40
|
+
expect(progressbar.valueCurrent).toBe(50)
|
|
41
|
+
expect(progressbar.getAttribute('role')).toBe('progressbar')
|
|
42
|
+
})
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
describe('Properties and attributes', () => {
|
|
46
|
+
test('applies default properties correctly', async () => {
|
|
47
|
+
const { progressbar } = await createProgressbarTest()
|
|
48
|
+
|
|
49
|
+
expect(progressbar.valueCurrent).toBe(0)
|
|
50
|
+
expect(progressbar.valueMin).toBe(0)
|
|
51
|
+
expect(progressbar.valueMax).toBe(100)
|
|
52
|
+
expect(progressbar.skin).toBe('dark-blue')
|
|
53
|
+
expect(progressbar.role).toBe('progressbar')
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
test('sets properties correctly', async () => {
|
|
57
|
+
const { progressbar } = await createProgressbarTest({
|
|
58
|
+
valueCurrent: 75,
|
|
59
|
+
valueMin: 10,
|
|
60
|
+
valueMax: 200,
|
|
61
|
+
skin: 'green',
|
|
62
|
+
title: 'Loading',
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
expect(progressbar.valueCurrent).toBe(75)
|
|
66
|
+
expect(progressbar.valueMin).toBe(10)
|
|
67
|
+
expect(progressbar.valueMax).toBe(200)
|
|
68
|
+
expect(progressbar.skin).toBe('green')
|
|
69
|
+
expect(progressbar.title).toBe('Loading')
|
|
70
|
+
})
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
describe('Skin variants', () => {
|
|
74
|
+
test('applies dark-blue skin correctly', async () => {
|
|
75
|
+
const { progressbar } = await createProgressbarTest({ skin: 'dark-blue' })
|
|
76
|
+
|
|
77
|
+
const barElement = progressbar.querySelector('.pkt-progressbar__bar')
|
|
78
|
+
expect(barElement?.classList.contains('pkt-progressbar__bar--dark-blue')).toBe(true)
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
test('applies green skin correctly', async () => {
|
|
82
|
+
const { progressbar } = await createProgressbarTest({ skin: 'green' })
|
|
83
|
+
|
|
84
|
+
const barElement = progressbar.querySelector('.pkt-progressbar__bar')
|
|
85
|
+
expect(barElement?.classList.contains('pkt-progressbar__bar--green')).toBe(true)
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
test('applies red skin correctly', async () => {
|
|
89
|
+
const { progressbar } = await createProgressbarTest({ skin: 'red' })
|
|
90
|
+
|
|
91
|
+
const barElement = progressbar.querySelector('.pkt-progressbar__bar')
|
|
92
|
+
expect(barElement?.classList.contains('pkt-progressbar__bar--red')).toBe(true)
|
|
93
|
+
})
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
describe('Status display', () => {
|
|
97
|
+
test('shows percentage when statusType is percentage', async () => {
|
|
98
|
+
const { progressbar } = await createProgressbarTest({
|
|
99
|
+
valueCurrent: 50,
|
|
100
|
+
statusType: 'percentage',
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
const statusElement = progressbar.querySelector('.pkt-progressbar__status')
|
|
104
|
+
expect(statusElement?.textContent).toContain('50%')
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
test('shows fraction when statusType is fraction', async () => {
|
|
108
|
+
const { progressbar } = await createProgressbarTest({
|
|
109
|
+
valueCurrent: 25,
|
|
110
|
+
valueMax: 50,
|
|
111
|
+
statusType: 'fraction',
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
const statusElement = progressbar.querySelector('.pkt-progressbar__status')
|
|
115
|
+
expect(statusElement?.textContent?.trim()).toContain('25 av 50')
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
test('hides status when statusType is none', async () => {
|
|
119
|
+
const { progressbar } = await createProgressbarTest({
|
|
120
|
+
valueCurrent: 50,
|
|
121
|
+
statusType: 'none',
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
const statusElement = progressbar.querySelector('.pkt-progressbar__status')
|
|
125
|
+
expect(statusElement).not.toBeInTheDocument()
|
|
126
|
+
})
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
describe('Title functionality', () => {
|
|
130
|
+
test('renders title when provided', async () => {
|
|
131
|
+
const { progressbar } = await createProgressbarTest({ title: 'Loading progress' })
|
|
132
|
+
|
|
133
|
+
const titleElement = progressbar.querySelector('.pkt-progressbar__title')
|
|
134
|
+
expect(titleElement).toBeInTheDocument()
|
|
135
|
+
expect(titleElement?.textContent).toBe('Loading progress')
|
|
136
|
+
})
|
|
137
|
+
|
|
138
|
+
test('does not render title when empty', async () => {
|
|
139
|
+
const { progressbar } = await createProgressbarTest()
|
|
140
|
+
|
|
141
|
+
const titleElement = progressbar.querySelector('.pkt-progressbar__title')
|
|
142
|
+
expect(titleElement).not.toBeInTheDocument()
|
|
143
|
+
})
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
describe('ARIA and accessibility', () => {
|
|
147
|
+
test('has correct ARIA attributes', async () => {
|
|
148
|
+
const { progressbar } = await createProgressbarTest({
|
|
149
|
+
valueCurrent: 60,
|
|
150
|
+
ariaLabel: 'File upload progress',
|
|
151
|
+
})
|
|
152
|
+
|
|
153
|
+
expect(progressbar.getAttribute('aria-valuemin')).toBe('0')
|
|
154
|
+
expect(progressbar.getAttribute('aria-valuemax')).toBe('100')
|
|
155
|
+
expect(progressbar.getAttribute('aria-valuenow')).toBe('60')
|
|
156
|
+
expect(progressbar.getAttribute('aria-label')).toBe('File upload progress')
|
|
157
|
+
})
|
|
158
|
+
|
|
159
|
+
test('updates aria-valuenow when value changes', async () => {
|
|
160
|
+
const { progressbar } = await createProgressbarTest({ valueCurrent: 30 })
|
|
161
|
+
|
|
162
|
+
progressbar.valueCurrent = 80
|
|
163
|
+
await progressbar.updateComplete
|
|
164
|
+
|
|
165
|
+
expect(progressbar.getAttribute('aria-valuenow')).toBe('80')
|
|
166
|
+
})
|
|
167
|
+
})
|
|
168
|
+
|
|
169
|
+
describe('Role variants', () => {
|
|
170
|
+
test('uses progressbar role by default', async () => {
|
|
171
|
+
const { progressbar } = await createProgressbarTest()
|
|
172
|
+
|
|
173
|
+
expect(progressbar.getAttribute('role')).toBe('progressbar')
|
|
174
|
+
})
|
|
175
|
+
|
|
176
|
+
test('uses meter role when specified', async () => {
|
|
177
|
+
const { progressbar } = await createProgressbarTest({ role: 'meter' })
|
|
178
|
+
|
|
179
|
+
expect(progressbar.getAttribute('role')).toBe('meter')
|
|
180
|
+
})
|
|
181
|
+
})
|
|
182
|
+
|
|
183
|
+
describe('Accessibility', () => {
|
|
184
|
+
test('progressbar is accessible', async () => {
|
|
185
|
+
const { container } = await createProgressbarTest({
|
|
186
|
+
title: 'Upload progress',
|
|
187
|
+
valueCurrent: 50,
|
|
188
|
+
ariaLabel: 'File upload progress',
|
|
189
|
+
})
|
|
190
|
+
|
|
191
|
+
const results = await axe(container)
|
|
192
|
+
expect(results).toHaveNoViolations()
|
|
193
|
+
})
|
|
194
|
+
})
|
|
195
|
+
})
|