Skip to content

Commit 0737ab3

Browse files
Boolean Facets (#106)
* Add BooleanFacetGroup + simplify facetOptions * Fix tests, rename SearchFilter -> FilterIndicator * add tests; update swc, add coverage * add a tests for filterable facet * rename facetMap -> facetManifest * do not render MultiFacetGroup when empty
1 parent 8d816ff commit 0737ab3

15 files changed

+707
-493
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
node_modules/
2+
coverage
23
dist/*
34
*.tgz
45

jest.config.ts

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,13 @@
1-
import { Config } from "@jest/types"
1+
import { Config } from "@jest/types";
22

3-
const common = {
3+
const config: Config.InitialOptions = {
44
testEnvironment: "jsdom",
5-
transform: {
5+
collectCoverage: true,
6+
transform: {
67
"^.+\\.(t)sx?$": "@swc/jest",
78
},
89
setupFilesAfterEnv: ["<rootDir>src/test_setup.ts"],
9-
testMatch: ["<rootDir>/src/**/*.(spec|test).ts?(x)"],
10-
}
11-
12-
const config: Config.InitialOptions = {
13-
projects: [
14-
{
15-
displayName: "history-v4",
16-
moduleNameMapper: {
17-
history$: "history-v4",
18-
},
19-
...common,
20-
},
21-
{
22-
displayName: "history-v5",
23-
moduleNameMapper: {
24-
history$: "history",
25-
},
26-
...common,
27-
},
28-
],
29-
}
10+
testMatch: ["<rootDir>/src/**/*.(spec|test).ts?(x)"],
11+
};
3012

31-
export default config
13+
export default config;

package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,17 @@
3838
"homepage": "https://github.com/mitodl/course-search-utils#readme",
3939
"dependencies": {
4040
"@mitodl/open-api-axios": "^2024.5.6",
41-
"@testing-library/react": "12",
42-
"@testing-library/user-event": "^14.5.2",
4341
"axios": "^1.6.7",
4442
"fuse.js": "^7.0.0",
4543
"query-string": "^6.13.1",
4644
"ramda": "^0.27.1"
4745
},
4846
"devDependencies": {
49-
"@swc/core": "^1.3.0",
50-
"@swc/jest": "^0.2.22",
47+
"@swc/core": "^1.5.7",
48+
"@swc/jest": "^0.2.36",
49+
"@testing-library/react": "12",
5150
"@testing-library/react-hooks": "^8.0.1",
51+
"@testing-library/user-event": "^14.5.2",
5252
"@types/enzyme": "^3.10.7",
5353
"@types/jest": "^29.0.1",
5454
"@types/lodash": "^4.14.162",
@@ -80,7 +80,8 @@
8080
"react": "^16.13.1",
8181
"react-dom": "^16.13.1",
8282
"react-router": "^6.22.2",
83-
"ts-node": "^10.9.1",
83+
"tiny-invariant": "^1.3.3",
84+
"ts-node": "^10.9.2",
8485
"typescript": "^5.3.3"
8586
},
8687
"peerDependencies": {

src/facet_display/Facet.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { useState } from "react"
22
import { contains } from "ramda"
33

44
import { SearchFacetItem } from "./SearchFacetItem"
5-
import { BucketWithLabel } from "./FacetDisplay"
5+
import { BucketWithLabel } from "./types"
66

77
const MAX_DISPLAY_COUNT = 5
88
const FACET_COLLAPSE_THRESHOLD = 15
@@ -40,17 +40,17 @@ function SearchFacet(props: Props) {
4040
{showFacetList ? (
4141
<>
4242
{results ?
43-
results.map((facet, i) =>
43+
results.map((bucket, i) =>
4444
showAllFacets ||
4545
i < MAX_DISPLAY_COUNT ||
4646
results.length < FACET_COLLAPSE_THRESHOLD ? (
4747
<SearchFacetItem
48-
key={`${name}-${facet.key}`}
49-
facet={facet}
50-
isChecked={contains(facet.key, selected || [])}
48+
key={`${name}-${bucket.key}`}
49+
bucket={bucket}
50+
isChecked={contains(bucket.key, selected || [])}
5151
onUpdate={onUpdate}
5252
name={name}
53-
displayKey={facet.label}
53+
displayKey={bucket.label}
5454
/>
5555
) : null
5656
) :

0 commit comments

Comments
 (0)