@navikt/ds-react 0.9.1 → 0.9.2
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@navikt/ds-react",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "NAV designsystem react components",
|
|
6
6
|
"author": "NAV Designsystem team",
|
|
@@ -30,7 +30,8 @@
|
|
|
30
30
|
"create-package-json-pointers-to-esm": "node ../../utilities/scripts/createPackageJsonsWithESMPointers.js",
|
|
31
31
|
"clean": "rimraf cjs esm",
|
|
32
32
|
"build": "yarn run clean && tsc && tsc -p tsconfig-esm.json && yarn create-package-json-pointers-to-esm",
|
|
33
|
-
"watch": "tsc --watch -p tsconfig-esm.json"
|
|
33
|
+
"watch": "tsc --watch -p tsconfig-esm.json",
|
|
34
|
+
"test": "jest"
|
|
34
35
|
},
|
|
35
36
|
"dependencies": {
|
|
36
37
|
"@material-ui/core": "^4.12.3",
|
|
@@ -45,15 +46,23 @@
|
|
|
45
46
|
"uuid": "^8.3.2"
|
|
46
47
|
},
|
|
47
48
|
"devDependencies": {
|
|
49
|
+
"@testing-library/jest-dom": "^5.14.1",
|
|
50
|
+
"@testing-library/react": "^12.1.0",
|
|
51
|
+
"@testing-library/user-event": "^13.2.1",
|
|
52
|
+
"@types/faker": "^5.5.8",
|
|
53
|
+
"@types/jest": "^27.0.1",
|
|
48
54
|
"@types/react-router-dom": "^5.1.9",
|
|
49
55
|
"@types/styled-components": "^5.1.14",
|
|
50
56
|
"copyfiles": "^2.4.1",
|
|
57
|
+
"faker": "^5.5.3",
|
|
58
|
+
"jest": "^27.2.0",
|
|
51
59
|
"react-router-dom": "^5.3.0",
|
|
52
60
|
"rimraf": "3.0.2",
|
|
53
|
-
"styled-components": "^5.3.1"
|
|
61
|
+
"styled-components": "^5.3.1",
|
|
62
|
+
"ts-jest": "^27.0.5"
|
|
54
63
|
},
|
|
55
64
|
"peerDependencies": {
|
|
56
65
|
"react": "^16.8.0 || ^17.0.0"
|
|
57
66
|
},
|
|
58
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "40d8d369a4c6c111cee4d89b7975bc343f066b3c"
|
|
59
68
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render, screen } from "@testing-library/react";
|
|
3
|
+
import userEvent from "@testing-library/user-event";
|
|
4
|
+
import faker from "faker";
|
|
5
|
+
import { Checkbox, CheckboxGroup } from ".";
|
|
6
|
+
|
|
7
|
+
test("checkbox group chains onChange calls", () => {
|
|
8
|
+
const onGroupChange = jest.fn();
|
|
9
|
+
const onChange = jest.fn();
|
|
10
|
+
const value = faker.datatype.string();
|
|
11
|
+
const label = faker.datatype.string();
|
|
12
|
+
|
|
13
|
+
render(
|
|
14
|
+
<CheckboxGroup legend="legend" onChange={onGroupChange}>
|
|
15
|
+
<Checkbox onChange={onChange} value={value}>
|
|
16
|
+
{label}
|
|
17
|
+
</Checkbox>
|
|
18
|
+
</CheckboxGroup>
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
userEvent.click(screen.getByLabelText(label));
|
|
22
|
+
|
|
23
|
+
expect(onGroupChange).toBeCalledTimes(1);
|
|
24
|
+
expect(onGroupChange).toBeCalledWith([value]);
|
|
25
|
+
expect(onChange).toBeCalledTimes(1);
|
|
26
|
+
expect(firstArgumentOfFirstCall(onChange).target.checked).toBe(true);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const firstArgumentOfFirstCall = (fn: jest.Mock) => fn.mock.calls[0][0];
|