Skip to content

Commit 4587c0a

Browse files
authored
[chore] Replace mocha with vitest in icons (#7983)
1 parent 4da50d6 commit 4587c0a

16 files changed

Lines changed: 111 additions & 101 deletions

packages/core/src/isotest.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ const config: Record<string, IsomorphicTestConfig> = {
116116
Popover: {
117117
children: requiredChild,
118118
},
119+
PopoverNext: {
120+
children: requiredChild,
121+
className: false,
122+
},
119123
Portal: {
120124
className: false,
121125
},
@@ -126,6 +130,9 @@ const config: Record<string, IsomorphicTestConfig> = {
126130
children: requiredChild,
127131
className: false,
128132
},
133+
SegmentedControl: {
134+
props: { options: [] },
135+
},
129136
TabPanel: {
130137
skip: true,
131138
},

packages/icons/package.json

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
"scripts": {
1919
"clean": "rm -rf dist/* || rm -rf lib/**/* || rm -rf src/generated/* || true",
2020
"compile": "npm-run-all -s \"generate-icon-src\" -p \"compile:*\" -p \"copy:*\"",
21-
"compile:esm": "tsc -p ./src",
22-
"compile:cjs": "tsc -p ./src -m commonjs --verbatimModuleSyntax false --outDir lib/cjs",
23-
"compile:esnext": "tsc -p ./src -t esnext --outDir lib/esnext",
21+
"compile:esm": "tsc -p ./src/tsconfig.build.json",
22+
"compile:cjs": "tsc -p ./src/tsconfig.build.json -m commonjs --verbatimModuleSyntax false --outDir lib/cjs",
23+
"compile:esnext": "tsc -p ./src/tsconfig.build.json -t esnext --outDir lib/esnext",
2424
"compile:css": "sass-compile ./src",
2525
"copy:scss": "scripts/copy-scss.sh",
2626
"copy:fonts": "scripts/copy-fonts.sh",
@@ -33,9 +33,11 @@
3333
"lint:scss": "sass-lint",
3434
"lint:es": "es-lint",
3535
"lint-fix": "es-lint --fix && sass-lint --fix",
36-
"test": "run-s test:typeCheck test:iso",
37-
"test:typeCheck": "tsc -p ./test",
38-
"test:iso": "mocha test/isotest.mjs",
36+
"test": "run-s test:typeCheck test:iso test:vitest:run",
37+
"test:typeCheck": "tsc -p ./src/tsconfig.test.json",
38+
"test:iso": "vitest run --config vitest.config.isotest.mts",
39+
"test:vitest": "vitest",
40+
"test:vitest:run": "vitest run",
3941
"verify": "npm-run-all compile -p dist test lint"
4042
},
4143
"dependencies": {
@@ -57,11 +59,12 @@
5759
"@blueprintjs/node-build-scripts": "workspace:^",
5860
"@blueprintjs/stylelint-plugin": "workspace:^",
5961
"@blueprintjs/test-commons": "workspace:^",
62+
"@testing-library/react": "catalog:",
6063
"@twbs/fantasticon": "^2.7.2",
64+
"@vitejs/plugin-react": "catalog:",
6165
"@types/handlebars": "^4.1.0",
62-
"enzyme": "^3.11.0",
6366
"handlebars": "^4.7.8",
64-
"mocha": "^10.2.0",
67+
"vitest": "catalog:",
6568
"npm-run-all": "^4.1.5",
6669
"react": "^18.3.1",
6770
"react-dom": "^18.3.1",

packages/icons/test/generatedIconsTests.tsx renamed to packages/icons/src/generatedIcons.test.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,20 @@
22
* Copyright 2023 Palantir Technologies, Inc. All rights reserved.
33
*/
44

5-
import { mount } from "enzyme";
5+
import { render } from "@testing-library/react";
6+
import { describe, it } from "vitest";
67

7-
import { Add } from "../src/generated/components";
8+
import { Add } from "./generated/components";
89

910
describe("<Add> icon component", () => {
1011
it("allows attaching an event handler", () => {
1112
const handleClick: React.MouseEventHandler<HTMLSpanElement> = () => undefined;
12-
mount(<Add onClick={handleClick} />);
13+
render(<Add onClick={handleClick} />);
1314
});
1415

1516
it("disallows child elements", () => {
1617
const handleClick: React.MouseEventHandler<HTMLSpanElement> = () => undefined;
17-
mount(
18+
render(
1819
<Add onClick={handleClick}>
1920
{/* @ts-expect-error */}
2021
<path />
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
* Copyright 2023 Palantir Technologies, Inc. All rights reserved.
33
*/
44

5-
import { getIconPaths } from "../src/allPaths";
6-
import { Icons } from "../src/iconLoader";
5+
import { describe, it } from "vitest";
6+
7+
import { getIconPaths } from "./allPaths";
8+
import { Icons } from "./iconLoader";
79

810
describe("IconLoader", () => {
911
it("is compatible with getIconPaths", () => {
Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
2-
* Copyright 2017 Palantir Technologies, Inc. All rights reserved.
2+
* Copyright 2026 Palantir Technologies, Inc. All rights reserved.
3+
*
34
* Licensed under the Apache License, Version 2.0 (the "License");
45
* you may not use this file except in compliance with the License.
56
* You may obtain a copy of the License at
@@ -13,24 +14,22 @@
1314
* limitations under the License.
1415
*/
1516

16-
// @ts-check
17-
18-
import "@blueprintjs/test-commons/bootstrap";
1917
import { createElement } from "react";
18+
import { describe } from "vitest";
2019

21-
import { generateIsomorphicTests } from "@blueprintjs/test-commons";
20+
import { generateIsomorphicTestsVitest } from "@blueprintjs/test-commons";
2221

23-
import Icons from "../lib/cjs/generated/index.js";
22+
import * as Icons from "./generated/index";
2423

2524
describe("@blueprintjs/icons isomorphic rendering", () => {
26-
generateIsomorphicTests(
25+
generateIsomorphicTestsVitest(
2726
Icons,
2827
{
2928
SVGIconContainer: {
29+
children: createElement("path"),
3030
props: {
3131
iconName: "add",
3232
},
33-
children: createElement("path"),
3433
},
3534
},
3635
{ excludedSymbols: ["Icons"] },

packages/icons/test/svgIconContainerTests.tsx renamed to packages/icons/src/svgIconContainer.test.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
* Copyright 2023 Palantir Technologies, Inc. All rights reserved.
33
*/
44

5-
import { mount } from "enzyme";
5+
import { render } from "@testing-library/react";
6+
import { describe, it } from "vitest";
67

7-
import { SVGIconContainer } from "../src/svgIconContainer";
8+
import { SVGIconContainer } from "./svgIconContainer";
89

910
describe("SVGIconContainer", () => {
1011
it("accepts generic type param specifying the type of the root element", () => {
1112
const handleClick: React.MouseEventHandler<HTMLSpanElement> = () => undefined;
12-
mount(
13+
render(
1314
<SVGIconContainer<HTMLSpanElement> iconName="add" onClick={handleClick}>
1415
<path />
1516
</SVGIconContainer>,
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "../../../config/tsconfig.web",
3+
"compilerOptions": {
4+
"composite": true,
5+
"outDir": "../lib/esm"
6+
},
7+
"exclude": ["**/*.test.ts", "**/*.test.tsx", "**/*.test.mts"]
8+
}

packages/icons/src/tsconfig.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
{
2-
"extends": "../../../config/tsconfig.web",
3-
"compilerOptions": {
4-
"outDir": "../lib/esm"
5-
}
2+
"files": [],
3+
"references": [{ "path": "./tsconfig.build.json" }, { "path": "./tsconfig.test.json" }]
64
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": "./tsconfig.build.json",
3+
"compilerOptions": {
4+
"composite": true,
5+
"noEmit": true,
6+
"skipLibCheck": true
7+
},
8+
"include": ["**/*.ts", "**/*.tsx", "**/*.test.ts", "**/*.test.tsx", "**/*.test.mts"],
9+
"exclude": []
10+
}

packages/icons/test/index.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)