@khanacademy/wonder-blocks-dropdown 2.5.1 → 2.5.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": "@khanacademy/wonder-blocks-dropdown",
3
- "version": "2.5.1",
3
+ "version": "2.5.2",
4
4
  "design": "v1",
5
5
  "description": "Dropdown variants for Wonder Blocks.",
6
6
  "main": "dist/index.js",
@@ -15,18 +15,18 @@
15
15
  "access": "public"
16
16
  },
17
17
  "dependencies": {
18
- "@babel/runtime": "^7.13.10",
19
- "@khanacademy/wonder-blocks-button": "^2.10.1",
20
- "@khanacademy/wonder-blocks-clickable": "^2.2.0",
21
- "@khanacademy/wonder-blocks-color": "^1.1.19",
22
- "@khanacademy/wonder-blocks-core": "^3.2.0",
23
- "@khanacademy/wonder-blocks-icon": "^1.2.23",
24
- "@khanacademy/wonder-blocks-icon-button": "^3.4.0",
25
- "@khanacademy/wonder-blocks-layout": "^1.4.5",
26
- "@khanacademy/wonder-blocks-modal": "^2.1.44",
27
- "@khanacademy/wonder-blocks-spacing": "^3.0.4",
28
- "@khanacademy/wonder-blocks-timing": "^2.0.2",
29
- "@khanacademy/wonder-blocks-typography": "^1.1.27"
18
+ "@babel/runtime": "^7.16.3",
19
+ "@khanacademy/wonder-blocks-button": "^2.10.2",
20
+ "@khanacademy/wonder-blocks-clickable": "^2.2.1",
21
+ "@khanacademy/wonder-blocks-color": "^1.1.20",
22
+ "@khanacademy/wonder-blocks-core": "^4.0.0",
23
+ "@khanacademy/wonder-blocks-icon": "^1.2.24",
24
+ "@khanacademy/wonder-blocks-icon-button": "^3.4.1",
25
+ "@khanacademy/wonder-blocks-layout": "^1.4.6",
26
+ "@khanacademy/wonder-blocks-modal": "^2.1.45",
27
+ "@khanacademy/wonder-blocks-spacing": "^3.0.5",
28
+ "@khanacademy/wonder-blocks-timing": "^2.0.3",
29
+ "@khanacademy/wonder-blocks-typography": "^1.1.28"
30
30
  },
31
31
  "peerDependencies": {
32
32
  "@popperjs/core": "^2.10.1",
@@ -39,7 +39,7 @@
39
39
  "react-window": "^1.8.5"
40
40
  },
41
41
  "devDependencies": {
42
- "wb-dev-build-settings": "^0.1.2"
42
+ "wb-dev-build-settings": "^0.2.0"
43
43
  },
44
- "gitHead": "61090a61b6e9d2a735976d5fd53a15d06f10c853"
44
+ "gitHead": "9ebea88533e702011165072f090a377e02fa3f0f"
45
45
  }
@@ -8,6 +8,8 @@ import SeparatorItem from "../separator-item.js";
8
8
  import DropdownCoreVirtualized from "../dropdown-core-virtualized.js";
9
9
  import SearchTextInput from "../search-text-input.js";
10
10
 
11
+ import {unmountAll} from "../../../../../utils/testing/enzyme-shim.js";
12
+
11
13
  describe("DropdownCoreVirtualized", () => {
12
14
  beforeEach(() => {
13
15
  jest.useFakeTimers();
@@ -24,6 +26,12 @@ describe("DropdownCoreVirtualized", () => {
24
26
  });
25
27
 
26
28
  afterEach(() => {
29
+ // We have to explicitly unmount before clearing mocks, otherwise jest
30
+ // timers will throw because we'll try to clear an animation frame that
31
+ // we set with a setTimeout but are clearing with clearAnimationFrame
32
+ // because we restored the clearAnimationFrame mock (and we won't
33
+ // have cleared the timeout we actually set!)
34
+ unmountAll();
27
35
  jest.restoreAllMocks();
28
36
  });
29
37
 
@@ -8,6 +8,8 @@ import SearchTextInput from "../search-text-input.js";
8
8
  import DropdownCore from "../dropdown-core.js";
9
9
  import {keyCodes} from "../../util/constants.js";
10
10
 
11
+ import {unmountAll} from "../../../../../utils/testing/enzyme-shim.js";
12
+
11
13
  jest.mock("../dropdown-core-virtualized.js");
12
14
 
13
15
  const elementAtIndex = (wrapper, index) =>
@@ -87,6 +89,12 @@ describe("DropdownCore", () => {
87
89
  });
88
90
 
89
91
  afterEach(() => {
92
+ // We have to explicitly unmount before clearing mocks, otherwise jest
93
+ // timers will throw because we'll try to clear an animation frame that
94
+ // we set with a setTimeout but are clearing with clearAnimationFrame
95
+ // because we restored the clearAnimationFrame mock (and we won't
96
+ // have cleared the timeout we actually set!)
97
+ unmountAll();
90
98
  jest.restoreAllMocks();
91
99
  });
92
100
 
@@ -14,6 +14,8 @@ import MultiSelect from "../multi-select.js";
14
14
  import {keyCodes} from "../../util/constants.js";
15
15
  import SearchTextInput from "../search-text-input.js";
16
16
 
17
+ import {unmountAll} from "../../../../../utils/testing/enzyme-shim.js";
18
+
17
19
  import type {Labels} from "../multi-select.js";
18
20
 
19
21
  jest.useFakeTimers();
@@ -68,6 +70,12 @@ describe("MultiSelect", () => {
68
70
  });
69
71
 
70
72
  afterEach(() => {
73
+ // We have to explicitly unmount before clearing mocks, otherwise jest
74
+ // timers will throw because we'll try to clear an animation frame that
75
+ // we set with a setTimeout but are clearing with clearAnimationFrame
76
+ // because we restored the clearAnimationFrame mock (and we won't
77
+ // have cleared the timeout we actually set!)
78
+ unmountAll();
71
79
  jest.restoreAllMocks();
72
80
  });
73
81
 
@@ -1,8 +1,6 @@
1
1
  //@flow
2
2
  import * as React from "react";
3
3
  import {render, screen} from "@testing-library/react";
4
- // eslint-disable-next-line import/no-unassigned-import
5
- import "@testing-library/jest-dom/extend-expect";
6
4
 
7
5
  import OptionItem from "../option-item.js";
8
6
  import SingleSelect from "../single-select.js";
@@ -25,8 +23,7 @@ describe("SingleSelect", () => {
25
23
  afterEach(() => {
26
24
  window.scrollTo.mockClear();
27
25
  onChange.mockReset();
28
- // $FlowIgnore[prop-missing]: Flow doesn't understand that we're mocking console.error
29
- console.error.mockReset(); // eslint-disable-line no-console
26
+ jest.spyOn(console, "error").mockReset();
30
27
  });
31
28
 
32
29
  afterEach(() => {
@@ -52,7 +49,7 @@ describe("SingleSelect", () => {
52
49
  userEvent.click(opener);
53
50
 
54
51
  // Assert
55
- expect(screen.queryByRole("listbox")).toBeInTheDocument();
52
+ expect(screen.getByRole("listbox")).toBeInTheDocument();
56
53
  });
57
54
 
58
55
  it("should focus the first item in the dropdown", () => {
@@ -121,9 +118,7 @@ describe("SingleSelect", () => {
121
118
  userEvent.keyboard(key);
122
119
 
123
120
  // Assert
124
- expect(
125
- screen.queryByRole("listbox"),
126
- ).toBeInTheDocument();
121
+ expect(screen.getByRole("listbox")).toBeInTheDocument();
127
122
  });
128
123
 
129
124
  it("should focus the first item in the dropdown", () => {
@@ -152,7 +147,7 @@ describe("SingleSelect", () => {
152
147
 
153
148
  // Assert
154
149
  expect(onChange).not.toHaveBeenCalled();
155
- expect(screen.queryByRole("listbox")).toBeInTheDocument();
150
+ expect(screen.getByRole("listbox")).toBeInTheDocument();
156
151
  });
157
152
 
158
153
  it("should select an item when pressing {space}", () => {
@@ -278,7 +273,7 @@ describe("SingleSelect", () => {
278
273
  userEvent.click(screen.getByText("Choose"));
279
274
 
280
275
  // Assert
281
- expect(screen.queryByRole("listbox")).toBeInTheDocument();
276
+ expect(screen.getByRole("listbox")).toBeInTheDocument();
282
277
  });
283
278
 
284
279
  it("closes the menu when the anchor is clicked", () => {
@@ -321,7 +316,7 @@ describe("SingleSelect", () => {
321
316
  userEvent.click(opener);
322
317
 
323
318
  // Assert
324
- expect(screen.queryByRole("listbox")).toBeInTheDocument();
319
+ expect(screen.getByRole("listbox")).toBeInTheDocument();
325
320
  });
326
321
 
327
322
  it("calls the custom onClick handler", () => {
@@ -14,8 +14,7 @@ import type {IconAsset} from "@khanacademy/wonder-blocks-icon";
14
14
  // If the intended icon is a check without a checkbox, you should be using
15
15
  // icons.check from the Wonder Blocks Icon package.
16
16
  const checkboxCheck: IconAsset = {
17
- small:
18
- "M11.263 4.324a1 1 0 1 1 1.474 1.352l-5.5 6a1 1 0 0 1-1.505-.036l-2.5-3a1 1 0 1 1 1.536-1.28L6.536 9.48l4.727-5.157z",
17
+ small: "M11.263 4.324a1 1 0 1 1 1.474 1.352l-5.5 6a1 1 0 0 1-1.505-.036l-2.5-3a1 1 0 1 1 1.536-1.28L6.536 9.48l4.727-5.157z",
19
18
  };
20
19
  const {blue, white, offBlack16, offBlack32, offBlack50, offWhite} = Color;
21
20
 
@@ -522,9 +522,8 @@ class DropdownCore extends React.Component<Props, State> {
522
522
  // appropriate item in handleKeyDown
523
523
  this.itemsClicked = true;
524
524
  this.focusedIndex = index;
525
- this.focusedOriginalIndex = this.state.itemRefs[
526
- this.focusedIndex
527
- ].originalIndex;
525
+ this.focusedOriginalIndex =
526
+ this.state.itemRefs[this.focusedIndex].originalIndex;
528
527
  };
529
528
 
530
529
  handleDropdownMouseUp: (event: SyntheticMouseEvent<>) => void = (event) => {
@@ -16,15 +16,8 @@ import {DROPDOWN_ITEM_HEIGHT} from "../util/constants.js";
16
16
 
17
17
  const StyledButton = addStyle("button");
18
18
 
19
- const {
20
- blue,
21
- white,
22
- white50,
23
- offBlack,
24
- offBlack16,
25
- offBlack32,
26
- offBlack64,
27
- } = Color;
19
+ const {blue, white, white50, offBlack, offBlack16, offBlack32, offBlack64} =
20
+ Color;
28
21
 
29
22
  type SelectOpenerProps = {|
30
23
  ...AriaProps,