Skip to content
This repository was archived by the owner on May 4, 2019. It is now read-only.

Commit da724aa

Browse files
authored
Merge pull request #209 from osu-cass/dev
Dev
2 parents 81c3f98 + 57297f7 commit da724aa

9 files changed

+931
-41
lines changed

src/Accessibility/AccessibilityModal.tsx

-4
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,6 @@ export class ItemAccessibilityModal extends React.Component<
109109
};
110110

111111
handleShowModal = () => {
112-
if (!this.state.showModal) {
113-
ga("send", "event", "button", "OpenAccessibility");
114-
}
115-
116112
this.setState({ showModal: true });
117113
};
118114

src/Filter/__tests__/CombinedFilter.test.tsx

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import "jsdom-global/register";
22
import * as React from "react";
3+
import * as CombinedFilterHelpers from "../CombinedFilterHelpers";
34
import { shallow, mount } from "enzyme";
45
import {
56
mockBasicFilterCategories,
@@ -10,9 +11,11 @@ import {
1011
AdvancedFilterContainer,
1112
BasicFilterContainer,
1213
CombinedFilter,
14+
CombinedFilterProps,
1315
AdvancedFilterCategoryModel,
1416
BasicFilterCategoryModel
1517
} from "@src/index";
18+
import { mockSeachAPI } from "./Mocks";
1619

1720
describe("FilterContainer", () => {
1821
const onFilterUpdated = jest.fn(
@@ -37,7 +40,15 @@ describe("FilterContainer", () => {
3740
it("renders", () => {
3841
expect(wrapper).toMatchSnapshot();
3942
});
40-
43+
it("filter updates", () => {
44+
expect(
45+
onFilterUpdated(
46+
mockSeachAPI,
47+
mockBasicFilterCategories,
48+
mockAdvancedFilterCategoriesAll
49+
)
50+
).toMatchSnapshot();
51+
});
4152
it("toggles the advanced filter", () => {
4253
expect(wrapper).toMatchSnapshot();
4354

src/Filter/__tests__/CombinedFilterHelpers.test.ts

+38
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
import * as CombinedFilterHelpers from "../CombinedFilterHelpers";
2+
import { ItemSearch } from "../../ItemSearch/ItemSearch";
23
import * as Mocks from "./Mocks";
34
import {
45
BasicFilterCategoryModel,
56
OptionTypeModel,
67
AdvancedFilterCategoryModel,
78
FilterType
89
} from "../FilterModels";
10+
import { siwFilterUpdated } from "gh-site/lib/src/Filter/CombinedFilterHelpers";
11+
import { SearchAPIParamsModel } from "gh-site/lib/src";
912

1013
const basicFilter: BasicFilterCategoryModel[] = [
1114
{ ...Mocks.claimSelectedCategory, optionType: OptionTypeModel.DropDown }
1215
];
16+
const emptyFilter: BasicFilterCategoryModel[] = [
17+
{ ...Mocks.claimSelectedCategory, optionType: OptionTypeModel.DropDown }
18+
];
1319
const advancedFilter: AdvancedFilterCategoryModel[] = [
1420
{
1521
...Mocks.claimSelectedCategory,
@@ -22,6 +28,7 @@ describe("resetFilters", () => {
2228
it("deselects all filters", () => {
2329
const advancedFilterClone = JSON.parse(JSON.stringify(advancedFilter));
2430
const basicFilterClone = JSON.parse(JSON.stringify(basicFilter));
31+
2532
const result = CombinedFilterHelpers.resetFilters(
2633
basicFilterClone,
2734
advancedFilterClone
@@ -35,6 +42,14 @@ describe("resetFilters", () => {
3542
expect(o.isSelected).toBeFalsy()
3643
);
3744
}
45+
46+
emptyFilter.forEach(o => (o.optionType = OptionTypeModel.inputBox));
47+
const inputBox = CombinedFilterHelpers.resetFilters(
48+
emptyFilter,
49+
advancedFilterClone
50+
);
51+
inputBox.basicFilter.forEach(f => expect(f.filterOptions).toHaveLength(0));
52+
3853
result.basicFilter[0].filterOptions.forEach(o =>
3954
expect(o.isSelected).toBeFalsy()
4055
);
@@ -138,3 +153,26 @@ describe("advancedFilterUpdated", () => {
138153
expect(result.basicFilter[0].filterOptions[1].isSelected).toBeTruthy();
139154
});
140155
});
156+
157+
describe("siwUpdateDependentAndSeach", () => {
158+
it("updates filter", () => {
159+
const basicFilterClone: BasicFilterCategoryModel[] = JSON.parse(
160+
JSON.stringify(basicFilter)
161+
);
162+
const advancedFilterClone: AdvancedFilterCategoryModel[] = JSON.parse(
163+
JSON.stringify(advancedFilter)
164+
);
165+
166+
const result = CombinedFilterHelpers.siwFilterUpdated(
167+
basicFilterClone,
168+
Mocks.mockSeachAPI,
169+
advancedFilterClone,
170+
Mocks.searchModel
171+
);
172+
const searchParams = ItemSearch.updateDependentSearchParams(
173+
Mocks.mockSeachAPI,
174+
Mocks.searchModel
175+
);
176+
expect(result.searchAPI).toEqual(searchParams);
177+
});
178+
});
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import * as React from "react";
2+
import { mount } from "enzyme";
3+
import "jsdom-global/register";
4+
import { FilterLink } from "@src/index";
5+
6+
const wrapper = mount(<FilterLink filterId="sb-filter-id" />);
7+
8+
it("filter link test", () => {
9+
wrapper.simulate("click");
10+
expect(wrapper).toMatchSnapshot();
11+
});

src/Filter/__tests__/Mocks.ts

+17-4
Original file line numberDiff line numberDiff line change
@@ -209,17 +209,20 @@ export const targets: TargetModel[] = [
209209
{
210210
name: "ELA1",
211211
nameHash: 21,
212-
idLabel: "21"
212+
idLabel: "21",
213+
id: "21"
213214
},
214215
{
215216
name: "MATH1",
216217
nameHash: 11,
217-
idLabel: "11"
218+
idLabel: "11",
219+
id: "11"
218220
},
219221
{
220222
name: "MATH2",
221223
nameHash: 12,
222-
idLabel: "12"
224+
idLabel: "12",
225+
id: "12"
223226
}
224227
];
225228

@@ -233,7 +236,17 @@ export const interactionTypes: InteractionTypeModel[] = [
233236
label: "ELA1"
234237
}
235238
];
236-
239+
export const mockSeachAPI: SearchAPIParamsModel = {
240+
itemId: "item1",
241+
// tslint:disable-next-line:no-bitwise
242+
gradeLevels: GradeLevels.Grade3 | GradeLevels.Grade4,
243+
subjects: ["t1", "t2"],
244+
claims: ["t1", "t2"],
245+
interactionTypes: ["t1", "t2"],
246+
performanceOnly: true,
247+
catOnly: true,
248+
targets: ["A", "B"]
249+
};
237250
export const searchModel: ItemsSearchModel = {
238251
interactionTypes,
239252
claims,

0 commit comments

Comments
 (0)