@inseefr/lunatic 3.4.14 → 3.4.16
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/components/shared/Label/Label.js +1 -1
- package/components/shared/Label/Label.js.map +1 -1
- package/components/shared/Label/Label.spec.js +11 -3
- package/components/shared/Label/Label.spec.js.map +1 -1
- package/esm/components/shared/Label/Label.js +1 -1
- package/esm/components/shared/Label/Label.js.map +1 -1
- package/esm/components/shared/Label/Label.spec.js +11 -3
- package/esm/components/shared/Label/Label.spec.js.map +1 -1
- package/esm/stories/overview/sourceWithHierarchy.json +5151 -0
- package/esm/tests/utils/lunatic.d.ts +0 -4
- package/esm/tests/utils/lunatic.js +0 -4
- package/esm/tests/utils/lunatic.js.map +1 -1
- package/esm/type.source.d.ts +1 -5
- package/esm/use-lunatic/commons/variables/get-questionnaire-data.js +0 -8
- package/esm/use-lunatic/commons/variables/get-questionnaire-data.js.map +1 -1
- package/esm/use-lunatic/commons/variables/lunatic-variables-store.spec.js +0 -8
- package/esm/use-lunatic/commons/variables/lunatic-variables-store.spec.js.map +1 -1
- package/esm/use-lunatic/hooks/useOverview.d.ts +1 -1
- package/esm/use-lunatic/hooks/useOverview.js +19 -14
- package/esm/use-lunatic/hooks/useOverview.js.map +1 -1
- package/esm/use-lunatic/hooks/useOverview.spec.d.ts +1 -0
- package/esm/use-lunatic/hooks/useOverview.spec.js +38 -0
- package/esm/use-lunatic/hooks/useOverview.spec.js.map +1 -0
- package/esm/use-lunatic/test.utils.d.ts +2 -0
- package/esm/use-lunatic/test.utils.js +13 -0
- package/esm/use-lunatic/test.utils.js.map +1 -0
- package/esm/use-lunatic/type.d.ts +0 -4
- package/esm/utils/constants/variable-status.d.ts +0 -4
- package/esm/utils/constants/variable-status.js +0 -4
- package/esm/utils/constants/variable-status.js.map +1 -1
- package/esm/utils/variables.spec.js +0 -8
- package/esm/utils/variables.spec.js.map +1 -1
- package/package.json +17 -57
- package/src/components/Input/__snapshots__/Input.spec.tsx.snap +11 -0
- package/src/components/shared/Label/Label.spec.tsx +15 -3
- package/src/components/shared/Label/Label.tsx +1 -1
- package/src/stories/accordion/source.json +1 -5
- package/src/stories/behaviour/cleaning/source-loop.json +3 -15
- package/src/stories/behaviour/cleaning/source.json +2 -10
- package/src/stories/behaviour/controls/boucles-n.json +2 -10
- package/src/stories/behaviour/controls/loop.json +2 -10
- package/src/stories/behaviour/controls/roundabout.json +3 -15
- package/src/stories/behaviour/controls/simple-numeric.json +19 -95
- package/src/stories/behaviour/controls/simple.json +7 -35
- package/src/stories/behaviour/filter/dataLoop.json +0 -8
- package/src/stories/behaviour/filter/source.json +0 -12
- package/src/stories/behaviour/filter/sourceLoop.json +0 -12
- package/src/stories/behaviour/missing/source.json +12 -60
- package/src/stories/behaviour/others/V2_DeclarationsSimples.json +14 -70
- package/src/stories/behaviour/others/V2_MinMaxSum_Boucles.json +5 -25
- package/src/stories/behaviour/others/V2_QuestSimple_Boucles.json +107 -535
- package/src/stories/behaviour/others/V2_TCMRallyeGames.json +33 -165
- package/src/stories/behaviour/others/test-dylan.json +5 -25
- package/src/stories/behaviour/paste/source.json +1 -5
- package/src/stories/behaviour/performance/source.json +4 -20
- package/src/stories/behaviour/resizing/source-resizing-cleaning.json +2 -10
- package/src/stories/behaviour/resizing/source.json +5 -25
- package/src/stories/checkbox-boolean/source.json +1 -5
- package/src/stories/checkbox-group/source.json +16 -80
- package/src/stories/checkbox-group/sourceCondition.json +3 -15
- package/src/stories/checkbox-group/sourceDetail.json +18 -90
- package/src/stories/checkbox-group/sourceLoop.json +2 -10
- package/src/stories/checkbox-one/source.json +1 -5
- package/src/stories/checkbox-one/sourceDetail.json +2 -10
- package/src/stories/date-picker/source.json +1 -5
- package/src/stories/declaration/source.json +2 -10
- package/src/stories/disabled/data.json +0 -16
- package/src/stories/disabled/source.json +7 -35
- package/src/stories/dropdown/data.json +2 -10
- package/src/stories/dropdown/source.json +2 -10
- package/src/stories/duration/mois.json +1 -5
- package/src/stories/duration/time.json +1 -5
- package/src/stories/filter-description/source-options.json +3 -15
- package/src/stories/input/source.json +1 -5
- package/src/stories/input-number/source-big-number.json +1 -5
- package/src/stories/input-number/source-euro.json +1 -5
- package/src/stories/input-number/source.json +1 -5
- package/src/stories/loop/source-bloc.json +2 -10
- package/src/stories/loop/source-paginated.json +2 -10
- package/src/stories/loop/source-roster.json +2 -10
- package/src/stories/loop/source-with-header.json +2 -10
- package/src/stories/overview/dataLoop.json +24 -120
- package/src/stories/overview/overview.stories.jsx +9 -0
- package/src/stories/overview/source.json +1 -5
- package/src/stories/overview/sourceLoop.json +24 -120
- package/src/stories/overview/sourceWithHierarchy.json +164 -820
- package/src/stories/pairwise/source.json +5 -25
- package/src/stories/question/source.json +2 -10
- package/src/stories/questionnaires/logement/data.json +0 -1288
- package/src/stories/questionnaires/logement/source-sequence.json +564 -2820
- package/src/stories/questionnaires/logement/source-sum.json +280 -1400
- package/src/stories/questionnaires/logement/source.json +564 -2820
- package/src/stories/questionnaires/recensement/source.json +106 -530
- package/src/stories/questionnaires/rp/source.json +8 -40
- package/src/stories/questionnaires/simpsons/source.json +104 -520
- package/src/stories/radio/source.json +1 -5
- package/src/stories/radio/sourceCondition.json +2 -10
- package/src/stories/radio/sourceDetail.json +2 -10
- package/src/stories/radio/sourceHorizontal.json +1 -5
- package/src/stories/roundabout/data1.json +0 -12
- package/src/stories/roundabout/data2.json +0 -16
- package/src/stories/roundabout/source.json +7 -35
- package/src/stories/suggester/source-arbitrary-response.json +6 -30
- package/src/stories/suggester/source-error.json +6 -30
- package/src/stories/suggester/source-multiline.json +0 -16
- package/src/stories/suggester/source-option-responses.json +5 -25
- package/src/stories/suggester/source.json +7 -35
- package/src/stories/summary/data.json +0 -16
- package/src/stories/summary/source.json +7 -35
- package/src/stories/switch/data-forced.json +2 -10
- package/src/stories/switch/source.json +4 -20
- package/src/stories/table/source-colspan.json +8 -40
- package/src/stories/table/table-dynamique.json +1 -5
- package/src/stories/text/source-roster.json +3 -15
- package/src/stories/text/source-table.json +9 -45
- package/src/stories/textarea/source.json +1 -5
- package/src/tests/utils/lunatic.ts +0 -4
- package/src/type.source.ts +1 -5
- package/src/use-lunatic/__snapshots__/use-lunatic.test.ts.snap +0 -1159
- package/src/use-lunatic/commons/variables/get-questionnaire-data.ts +0 -12
- package/src/use-lunatic/commons/variables/lunatic-variables-store.spec.ts +0 -8
- package/src/use-lunatic/hooks/useOverview.spec.ts +42 -0
- package/src/use-lunatic/hooks/useOverview.ts +41 -18
- package/src/use-lunatic/test.utils.ts +17 -0
- package/src/use-lunatic/type.ts +0 -4
- package/src/use-lunatic/use-lunatic.test.ts +2 -21
- package/src/utils/constants/variable-status.ts +0 -4
- package/src/utils/variables.spec.ts +0 -8
- package/stories/overview/sourceWithHierarchy.json +5151 -0
- package/tests/utils/lunatic.d.ts +0 -4
- package/tests/utils/lunatic.js +0 -4
- package/tests/utils/lunatic.js.map +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/type.source.d.ts +1 -5
- package/use-lunatic/commons/variables/get-questionnaire-data.js +0 -8
- package/use-lunatic/commons/variables/get-questionnaire-data.js.map +1 -1
- package/use-lunatic/commons/variables/lunatic-variables-store.spec.js +0 -8
- package/use-lunatic/commons/variables/lunatic-variables-store.spec.js.map +1 -1
- package/use-lunatic/hooks/useOverview.d.ts +1 -1
- package/use-lunatic/hooks/useOverview.js +19 -14
- package/use-lunatic/hooks/useOverview.js.map +1 -1
- package/use-lunatic/hooks/useOverview.spec.d.ts +1 -0
- package/use-lunatic/hooks/useOverview.spec.js +43 -0
- package/use-lunatic/hooks/useOverview.spec.js.map +1 -0
- package/use-lunatic/test.utils.d.ts +2 -0
- package/use-lunatic/test.utils.js +17 -0
- package/use-lunatic/test.utils.js.map +1 -0
- package/use-lunatic/type.d.ts +0 -4
- package/utils/constants/variable-status.d.ts +0 -4
- package/utils/constants/variable-status.js +1 -5
- package/utils/constants/variable-status.js.map +1 -1
- package/utils/variables.spec.js +0 -8
- package/utils/variables.spec.js.map +1 -1
- package/constants/component-types.d.ts +0 -1
- package/constants/component-types.js +0 -5
- package/constants/component-types.js.map +0 -1
- package/constants/declarations.d.ts +0 -9
- package/constants/declarations.js +0 -15
- package/constants/declarations.js.map +0 -1
- package/constants/event-types.d.ts +0 -10
- package/constants/event-types.js +0 -16
- package/constants/event-types.js.map +0 -1
- package/constants/index.d.ts +0 -5
- package/constants/index.js +0 -22
- package/constants/index.js.map +0 -1
- package/constants/indexedDBStore.d.ts +0 -21
- package/constants/indexedDBStore.js +0 -22
- package/constants/indexedDBStore.js.map +0 -1
- package/constants/supported-preferences.d.ts +0 -1
- package/constants/supported-preferences.js +0 -36
- package/constants/supported-preferences.js.map +0 -1
- package/constants/value-types.d.ts +0 -5
- package/constants/value-types.js +0 -9
- package/constants/value-types.js.map +0 -1
- package/constants/variable-types.d.ts +0 -2
- package/constants/variable-types.js +0 -8
- package/constants/variable-types.js.map +0 -1
- package/esm/constants/component-types.d.ts +0 -1
- package/esm/constants/component-types.js +0 -2
- package/esm/constants/component-types.js.map +0 -1
- package/esm/constants/declarations.d.ts +0 -9
- package/esm/constants/declarations.js +0 -12
- package/esm/constants/declarations.js.map +0 -1
- package/esm/constants/event-types.d.ts +0 -10
- package/esm/constants/event-types.js +0 -13
- package/esm/constants/event-types.js.map +0 -1
- package/esm/constants/index.d.ts +0 -5
- package/esm/constants/index.js +0 -6
- package/esm/constants/index.js.map +0 -1
- package/esm/constants/indexedDBStore.d.ts +0 -21
- package/esm/constants/indexedDBStore.js +0 -19
- package/esm/constants/indexedDBStore.js.map +0 -1
- package/esm/constants/supported-preferences.d.ts +0 -1
- package/esm/constants/supported-preferences.js +0 -10
- package/esm/constants/supported-preferences.js.map +0 -1
- package/esm/constants/value-types.d.ts +0 -5
- package/esm/constants/value-types.js +0 -6
- package/esm/constants/value-types.js.map +0 -1
- package/esm/constants/variable-types.d.ts +0 -2
- package/esm/constants/variable-types.js +0 -5
- package/esm/constants/variable-types.js.map +0 -1
- package/src/constants/component-types.ts +0 -1
- package/src/constants/declarations.ts +0 -14
- package/src/constants/event-types.ts +0 -13
- package/src/constants/index.ts +0 -5
- package/src/constants/indexedDBStore.ts +0 -20
- package/src/constants/supported-preferences.ts +0 -10
- package/src/constants/value-types.ts +0 -5
- package/src/constants/variable-types.ts +0 -4
|
@@ -12,7 +12,7 @@ const LabelDescription_1 = require("../LabelDescription");
|
|
|
12
12
|
* Label displayed on top of a field
|
|
13
13
|
*/
|
|
14
14
|
function LunaticLabel({ children, id, htmlFor, className, style, description, }) {
|
|
15
|
-
if (!children) {
|
|
15
|
+
if (!children && !description) {
|
|
16
16
|
return null;
|
|
17
17
|
}
|
|
18
18
|
return ((0, jsx_runtime_1.jsxs)("label", { htmlFor: htmlFor, id: id, className: (0, classnames_1.default)('lunatic-label', className), style: style, children: [children, (0, jsx_runtime_1.jsx)(LabelDescription_1.LabelDescription, { value: description })] }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Label.js","sourceRoot":"","sources":["../../../src/components/shared/Label/Label.tsx"],"names":[],"mappings":";;;;;;;AAKA,4DAAoC;AACpC,kEAA+D;AAC/D,0DAAuD;AAWvD;;GAEG;AACH,SAAS,YAAY,CAAC,EACrB,QAAQ,EACR,EAAE,EACF,OAAO,EACP,SAAS,EACT,KAAK,EACL,WAAW,GACJ;IACP,IAAI,CAAC,QAAQ,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"Label.js","sourceRoot":"","sources":["../../../src/components/shared/Label/Label.tsx"],"names":[],"mappings":";;;;;;;AAKA,4DAAoC;AACpC,kEAA+D;AAC/D,0DAAuD;AAWvD;;GAEG;AACH,SAAS,YAAY,CAAC,EACrB,QAAQ,EACR,EAAE,EACF,OAAO,EACP,SAAS,EACT,KAAK,EACL,WAAW,GACJ;IACP,IAAI,CAAC,QAAQ,IAAI,CAAC,WAAW,EAAE,CAAC;QAC/B,OAAO,IAAI,CAAC;IACb,CAAC;IACD,OAAO,CACN,mCACC,OAAO,EAAE,OAAO,EAChB,EAAE,EAAE,EAAE,EACN,SAAS,EAAE,IAAA,oBAAU,EAAC,eAAe,EAAE,SAAS,CAAC,EACjD,KAAK,EAAE,KAAK,aAEX,QAAQ,EACT,uBAAC,mCAAgB,IAAC,KAAK,EAAE,WAAW,GAAI,IACjC,CACR,CAAC;AACH,CAAC;AAEY,QAAA,KAAK,GAAG,IAAA,uCAAkB,EAAC,OAAO,EAAE,YAAY,CAAC,CAAC"}
|
|
@@ -5,17 +5,25 @@ const react_1 = require("@testing-library/react");
|
|
|
5
5
|
const Label_1 = require("./Label");
|
|
6
6
|
const vitest_1 = require("vitest");
|
|
7
7
|
(0, vitest_1.describe)('Label', () => {
|
|
8
|
-
(0, vitest_1.it)('renders null when children
|
|
9
|
-
const { container } = (0, react_1.render)((0, jsx_runtime_1.jsx)(Label_1.Label, { htmlFor: "input", id: "label",
|
|
8
|
+
(0, vitest_1.it)('renders null when children and description are falsy', () => {
|
|
9
|
+
const { container } = (0, react_1.render)((0, jsx_runtime_1.jsx)(Label_1.Label, { htmlFor: "input", id: "label", children: null }));
|
|
10
10
|
(0, vitest_1.expect)(container.firstChild).toBeNull();
|
|
11
11
|
});
|
|
12
12
|
(0, vitest_1.it)('renders a label without description', () => {
|
|
13
13
|
const { getByText, queryByText } = (0, react_1.render)((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Label_1.Label, { htmlFor: "kze792d8", id: "label", children: (0, jsx_runtime_1.jsx)("p", { children: "Name" }) }), (0, jsx_runtime_1.jsx)("input", { id: "kze792d8", className: "", type: "number", "aria-labelledby": "label", min: "0", max: "10", value: "", lang: "en" })] }));
|
|
14
14
|
const label = getByText('Name');
|
|
15
15
|
(0, vitest_1.expect)(label).toBeInTheDocument();
|
|
16
|
-
(0, vitest_1.expect)(label.
|
|
16
|
+
(0, vitest_1.expect)(label.closest('label')).toHaveAttribute('for', 'kze792d8');
|
|
17
17
|
const description = queryByText('This is a label');
|
|
18
18
|
(0, vitest_1.expect)(description).not.toBeInTheDocument();
|
|
19
19
|
});
|
|
20
|
+
(0, vitest_1.it)('renders a label with description and no label', () => {
|
|
21
|
+
const { container, queryByText } = (0, react_1.render)((0, jsx_runtime_1.jsx)(Label_1.Label, { htmlFor: "kze792d8", id: "label", description: "This is a label" }));
|
|
22
|
+
const label = container.querySelector('label');
|
|
23
|
+
(0, vitest_1.expect)(label).toBeInTheDocument();
|
|
24
|
+
(0, vitest_1.expect)(label).toHaveAttribute('for', 'kze792d8');
|
|
25
|
+
const description = queryByText('This is a label');
|
|
26
|
+
(0, vitest_1.expect)(description).toBeInTheDocument();
|
|
27
|
+
});
|
|
20
28
|
});
|
|
21
29
|
//# sourceMappingURL=Label.spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Label.spec.js","sourceRoot":"","sources":["../../../src/components/shared/Label/Label.spec.tsx"],"names":[],"mappings":";;;AAAA,kDAAgD;AAChD,mCAAgC;AAChC,mCAA8C;AAE9C,IAAA,iBAAQ,EAAC,OAAO,EAAE,GAAG,EAAE;IACtB,IAAA,WAAE,EAAC,
|
|
1
|
+
{"version":3,"file":"Label.spec.js","sourceRoot":"","sources":["../../../src/components/shared/Label/Label.spec.tsx"],"names":[],"mappings":";;;AAAA,kDAAgD;AAChD,mCAAgC;AAChC,mCAA8C;AAE9C,IAAA,iBAAQ,EAAC,OAAO,EAAE,GAAG,EAAE;IACtB,IAAA,WAAE,EAAC,sDAAsD,EAAE,GAAG,EAAE;QAC/D,MAAM,EAAE,SAAS,EAAE,GAAG,IAAA,cAAM,EAC3B,uBAAC,aAAK,IAAC,OAAO,EAAC,OAAO,EAAC,EAAE,EAAC,OAAO,YAC/B,IAAI,GACE,CACR,CAAC;QAEF,IAAA,eAAM,EAAC,SAAS,CAAC,UAAU,CAAC,CAAC,QAAQ,EAAE,CAAC;IACzC,CAAC,CAAC,CAAC;IAEH,IAAA,WAAE,EAAC,qCAAqC,EAAE,GA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B,CAAC,CAAC;QACnD,IAAA,eAAM,EAAC,WAAW,CAAC,CAAC,iBAAiB,EAAE,CAAC;IACzC,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
|
@@ -6,7 +6,7 @@ import { LabelDescription } from '../LabelDescription';
|
|
|
6
6
|
* Label displayed on top of a field
|
|
7
7
|
*/
|
|
8
8
|
function LunaticLabel({ children, id, htmlFor, className, style, description, }) {
|
|
9
|
-
if (!children) {
|
|
9
|
+
if (!children && !description) {
|
|
10
10
|
return null;
|
|
11
11
|
}
|
|
12
12
|
return (_jsxs("label", { htmlFor: htmlFor, id: id, className: classnames('lunatic-label', className), style: style, children: [children, _jsx(LabelDescription, { value: description })] }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Label.js","sourceRoot":"","sources":["../../../../src/components/shared/Label/Label.tsx"],"names":[],"mappings":";AAKA,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAWvD;;GAEG;AACH,SAAS,YAAY,CAAC,EACrB,QAAQ,EACR,EAAE,EACF,OAAO,EACP,SAAS,EACT,KAAK,EACL,WAAW,GACJ;IACP,IAAI,CAAC,QAAQ,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"Label.js","sourceRoot":"","sources":["../../../../src/components/shared/Label/Label.tsx"],"names":[],"mappings":";AAKA,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAWvD;;GAEG;AACH,SAAS,YAAY,CAAC,EACrB,QAAQ,EACR,EAAE,EACF,OAAO,EACP,SAAS,EACT,KAAK,EACL,WAAW,GACJ;IACP,IAAI,CAAC,QAAQ,IAAI,CAAC,WAAW,EAAE,CAAC;QAC/B,OAAO,IAAI,CAAC;IACb,CAAC;IACD,OAAO,CACN,iBACC,OAAO,EAAE,OAAO,EAChB,EAAE,EAAE,EAAE,EACN,SAAS,EAAE,UAAU,CAAC,eAAe,EAAE,SAAS,CAAC,EACjD,KAAK,EAAE,KAAK,aAEX,QAAQ,EACT,KAAC,gBAAgB,IAAC,KAAK,EAAE,WAAW,GAAI,IACjC,CACR,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,KAAK,GAAG,kBAAkB,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC"}
|
|
@@ -3,17 +3,25 @@ import { render } from '@testing-library/react';
|
|
|
3
3
|
import { Label } from './Label';
|
|
4
4
|
import { describe, it, expect } from 'vitest';
|
|
5
5
|
describe('Label', () => {
|
|
6
|
-
it('renders null when children
|
|
7
|
-
const { container } = render(_jsx(Label, { htmlFor: "input", id: "label",
|
|
6
|
+
it('renders null when children and description are falsy', () => {
|
|
7
|
+
const { container } = render(_jsx(Label, { htmlFor: "input", id: "label", children: null }));
|
|
8
8
|
expect(container.firstChild).toBeNull();
|
|
9
9
|
});
|
|
10
10
|
it('renders a label without description', () => {
|
|
11
11
|
const { getByText, queryByText } = render(_jsxs(_Fragment, { children: [_jsx(Label, { htmlFor: "kze792d8", id: "label", children: _jsx("p", { children: "Name" }) }), _jsx("input", { id: "kze792d8", className: "", type: "number", "aria-labelledby": "label", min: "0", max: "10", value: "", lang: "en" })] }));
|
|
12
12
|
const label = getByText('Name');
|
|
13
13
|
expect(label).toBeInTheDocument();
|
|
14
|
-
expect(label.
|
|
14
|
+
expect(label.closest('label')).toHaveAttribute('for', 'kze792d8');
|
|
15
15
|
const description = queryByText('This is a label');
|
|
16
16
|
expect(description).not.toBeInTheDocument();
|
|
17
17
|
});
|
|
18
|
+
it('renders a label with description and no label', () => {
|
|
19
|
+
const { container, queryByText } = render(_jsx(Label, { htmlFor: "kze792d8", id: "label", description: "This is a label" }));
|
|
20
|
+
const label = container.querySelector('label');
|
|
21
|
+
expect(label).toBeInTheDocument();
|
|
22
|
+
expect(label).toHaveAttribute('for', 'kze792d8');
|
|
23
|
+
const description = queryByText('This is a label');
|
|
24
|
+
expect(description).toBeInTheDocument();
|
|
25
|
+
});
|
|
18
26
|
});
|
|
19
27
|
//# sourceMappingURL=Label.spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Label.spec.js","sourceRoot":"","sources":["../../../../src/components/shared/Label/Label.spec.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE9C,QAAQ,CAAC,OAAO,EAAE,GAAG,EAAE;IACtB,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"Label.spec.js","sourceRoot":"","sources":["../../../../src/components/shared/Label/Label.spec.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE9C,QAAQ,CAAC,OAAO,EAAE,GAAG,EAAE;IACtB,EAAE,CAAC,sDAAsD,EAAE,GAAG,EAAE;QAC/D,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CAC3B,KAAC,KAAK,IAAC,OAAO,EAAC,OAAO,EAAC,EAAE,EAAC,OAAO,YAC/B,IAAI,GACE,CACR,CAAC;QAEF,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,QAAQ,EAAE,CAAC;IACzC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,qCAAqC,EAAE,GAAG,EAAE;QAC9C,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,GAAG,MAAM,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