Skip to content

Commit 931ebcd

Browse files
authored
Merge pull request #197 from clhenrick/migrate-vitest
fix: migrate tests to vitest
2 parents 97d547b + ec0f34c commit 931ebcd

File tree

75 files changed

+1686
-502
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+1686
-502
lines changed

website/.yarn/install-state.gz

99.1 KB
Binary file not shown.

website/eslint.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default defineConfig([
1313
{
1414
files: ["**/*.{js,mjs,cjs}"],
1515
languageOptions: {
16-
globals: { ...globals.browser, ...globals.node, ...globals.jest },
16+
globals: { ...globals.browser, ...globals.node, ...globals.vitest },
1717
},
1818
},
1919
{

website/package.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
"js:lint": "eslint src/**/*.js",
3131
"js:lint-fix": "yarn js:lint --fix",
3232
"format": "prettier --write .",
33-
"test": "echo \"Error: no test specified\" && exit 1",
33+
"test": "vitest run",
34+
"test:watch": "vitest",
3435
"postinstall": "cd .. && husky website/.husky",
3536
"prepublishOnly": "pinst --disable",
3637
"postpublish": "pinst --enable"
@@ -50,7 +51,7 @@
5051
"lodash.throttle": "4.1.1",
5152
"redux": "4.0.5",
5253
"redux-logger": "3.0.6",
53-
"redux-thunk": "2.3.0",
54+
"redux-thunk": "3.1.0",
5455
"single-line-string": "0.0.2"
5556
},
5657
"devDependencies": {
@@ -67,6 +68,7 @@
6768
"eslint-config-prettier": "^10.1.5",
6869
"globals": "^16.2.0",
6970
"husky": ">=6",
71+
"jsdom": "^29.0.0",
7072
"lint-staged": ">=10",
7173
"npm-run-all": "^4.1.5",
7274
"pinst": ">=2",
@@ -75,7 +77,9 @@
7577
"prettier": "3.5.3",
7678
"sass": "^1.87.0",
7779
"stylelint": "^16.20.0",
78-
"stylelint-config-standard-scss": "^15.0.1"
80+
"stylelint-config-standard-scss": "^15.0.1",
81+
"vitest": "^4.1.0",
82+
"vitest-fetch-mock": "^0.4.5"
7983
},
8084
"browserslist": {
8185
"production": [

website/src/js/action_creators/addressGeocodeActions.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import * as types from "../constants/actionTypes";
2-
import { geosearchApiVersion } from "../constants/config";
1+
import * as types from "../constants/actionTypes.js";
2+
import { geosearchApiVersion } from "../constants/config.js";
33

44
export const resetAddressState = () => ({
55
type: types.ResetAddressState,

website/src/js/action_creators/addressGeocodeActions.spec.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
import configureMockStore from "redux-mock-store";
2-
import thunk from "redux-thunk";
3-
import * as actions from "./addressGeocodeActions";
4-
import * as types from "../constants/actionTypes";
5-
6-
const middlewares = [thunk];
7-
const mockStore = configureMockStore(middlewares);
1+
import * as actions from "./addressGeocodeActions.js";
2+
import * as types from "../constants/actionTypes.js";
3+
import { createTestStore } from "../test-helpers.js";
84

95
describe("addressGeocodeActions", () => {
106
beforeEach(() => {
@@ -48,7 +44,7 @@ describe("addressGeocodeActions", () => {
4844
{ type: types.AddressSearchRequest },
4945
{ type: types.AddressSearchSuccess, payload: { features: [] } },
5046
];
51-
const store = mockStore({
47+
const store = createTestStore({
5248
addressGeocode: { searchResult: null, status: "idle", error: null },
5349
});
5450

@@ -69,7 +65,7 @@ describe("addressGeocodeActions", () => {
6965
error: new Error("Something bad happened"),
7066
},
7167
];
72-
const store = mockStore({
68+
const store = createTestStore({
7369
addressGeocode: { searchResult: null, status: "idle", error: null },
7470
});
7571

@@ -111,7 +107,7 @@ describe("addressGeocodeActions", () => {
111107
{ type: types.AddressAutosuggestRequest },
112108
{ type: types.AddressAutosuggestSuccess, payload: { features: [] } },
113109
];
114-
const store = mockStore({
110+
const store = createTestStore({
115111
addressGeocode: { autosuggestions: null, status: "idle", error: null },
116112
});
117113

@@ -132,7 +128,7 @@ describe("addressGeocodeActions", () => {
132128
error: new Error("Something bad happened"),
133129
},
134130
];
135-
const store = mockStore({
131+
const store = createTestStore({
136132
addressGeocode: { autosuggestions: null, status: "idle", error: null },
137133
});
138134

website/src/js/action_creators/globalActions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ResetAppState } from "../constants/actionTypes";
1+
import { ResetAppState } from "../constants/actionTypes.js";
22

33
export const resetAppState = () => ({
44
type: ResetAppState,

website/src/js/action_creators/globalActions.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { resetAppState } from "./globalActions";
1+
import { resetAppState } from "./globalActions.js";
22

33
describe("global action creators", () => {
44
test("resetAppState", () => {
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
export * from "./slidesActions";
2-
export * from "./addressGeocodeActions";
3-
export * from "./rentStabilizedActions";
4-
export * from "./searchRentStabilizedActions";
5-
export * from "./globalActions";
1+
export * from "./slidesActions.js";
2+
export * from "./addressGeocodeActions.js";
3+
export * from "./rentStabilizedActions.js";
4+
export * from "./searchRentStabilizedActions.js";
5+
export * from "./globalActions.js";

website/src/js/action_creators/rentStabilizedActions.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { cartoAPIv3BaseURL } from "../constants/config";
2-
import { rentStabilizedBblSql } from "../utils/sql";
3-
import { getCartoSqlApiAuthOptions } from "../utils/cartoSqlApiAuth";
4-
import * as types from "../constants/actionTypes";
1+
import { cartoAPIv3BaseURL } from "../constants/config.js";
2+
import { rentStabilizedBblSql } from "../utils/sql.js";
3+
import { getCartoSqlApiAuthOptions } from "../utils/cartoSqlApiAuth.js";
4+
import * as types from "../constants/actionTypes.js";
55

66
export const rentStabilizedRequest = () => ({
77
type: types.RentStabilizedRequest,

website/src/js/action_creators/rentStabilizedActions.spec.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
1-
import configureMockStore from "redux-mock-store";
2-
import thunk from "redux-thunk";
3-
import * as types from "../constants/actionTypes";
4-
import * as actions from "./rentStabilizedActions";
5-
6-
const middlewares = [thunk];
7-
const mockStore = configureMockStore(middlewares);
1+
import * as types from "../constants/actionTypes.js";
2+
import * as actions from "./rentStabilizedActions.js";
3+
import { createTestStore } from "../test-helpers.js";
84

95
describe("rentStabilizedActions", () => {
106
let store;
117

128
beforeEach(() => {
139
fetch.resetMocks();
14-
store = mockStore({
10+
store = createTestStore({
1511
rentStabilized: {
1612
status: "idle",
1713
error: null,

0 commit comments

Comments
 (0)