-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
163 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@navikt/ds-react": patch | ||
--- | ||
|
||
Modal: Bedre feilmeldinger ved feil bruk av props |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import { expectTypeOf } from "vitest"; | ||
import { ModalProps } from "./types"; | ||
|
||
test("ModalProps works as intended", () => { | ||
expectTypeOf({ | ||
header: { heading: "Label" }, | ||
children: "OK", | ||
}).toMatchTypeOf<ModalProps>(); | ||
|
||
expectTypeOf({ | ||
header: { heading: "Label" }, | ||
"aria-label": "Label", | ||
children: "OK", | ||
}).toMatchTypeOf<ModalProps>(); | ||
|
||
expectTypeOf({ | ||
header: { heading: "Label" }, | ||
"aria-labelledby": "Label", | ||
children: "OK", | ||
}).toMatchTypeOf<ModalProps>(); | ||
|
||
expectTypeOf({ | ||
"aria-label": "Label", | ||
children: "OK", | ||
}).toMatchTypeOf<ModalProps>(); | ||
|
||
expectTypeOf({ | ||
"aria-labelledby": "Label", | ||
children: "OK", | ||
}).toMatchTypeOf<ModalProps>(); | ||
|
||
expectTypeOf({ | ||
"aria-label": "Label", | ||
open: true, | ||
onClose: () => null, | ||
children: "OK", | ||
}).toMatchTypeOf<ModalProps>(); | ||
|
||
expectTypeOf({ | ||
children: "Mangler label", | ||
}).not.toMatchTypeOf<ModalProps>(); | ||
|
||
expectTypeOf({ | ||
open: true, | ||
children: "Mangler onClose eller label", | ||
}).not.toMatchTypeOf<ModalProps>(); | ||
|
||
expectTypeOf({ | ||
open: true, | ||
"aria-label": "Label", | ||
children: "Mangler onClose", | ||
}).not.toMatchTypeOf<ModalProps>(); | ||
|
||
expectTypeOf({ | ||
open: true, | ||
onClose: () => null, | ||
children: "Mangler label", | ||
}).not.toMatchTypeOf<ModalProps>(); | ||
|
||
expectTypeOf({ | ||
header: { heading: "Label" }, | ||
open: true, | ||
children: "Mangler onClose", | ||
}).not.toMatchTypeOf<ModalProps>(); | ||
|
||
expectTypeOf({ | ||
header: { heading: "Label" }, | ||
"aria-label": "Label", | ||
"aria-labelledby": "Label", | ||
children: "For mange labels", | ||
}).not.toMatchTypeOf<ModalProps>(); | ||
|
||
expectTypeOf({ | ||
"aria-label": "Label", | ||
"aria-labelledby": "Label", | ||
children: "For mange labels", | ||
}).not.toMatchTypeOf<ModalProps>(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters