@truedat/bg 6.3.2 → 6.3.4
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 +6 -6
- package/src/concepts/api.js +3 -7
- package/src/concepts/components/ConceptActions.js +1 -0
- package/src/concepts/components/ConceptCreate.js +6 -4
- package/src/concepts/components/ConceptRoutes.js +10 -33
- package/src/concepts/components/Concepts.js +25 -16
- package/src/concepts/components/ConceptsActions.js +8 -14
- package/src/concepts/components/ConceptsBulkUpdate.js +25 -64
- package/src/concepts/components/ConceptsLabelResults.js +13 -26
- package/src/concepts/components/ConceptsLinksManagement.js +6 -92
- package/src/concepts/components/ConceptsPagination.js +13 -11
- package/src/concepts/components/ConceptsPanel.js +51 -22
- package/src/concepts/components/ConceptsTable.js +77 -106
- package/src/concepts/components/ConceptsUpdateButton.js +49 -37
- package/src/concepts/components/DomainConcepts.js +2 -11
- package/src/concepts/components/LinkedMessage.js +81 -0
- package/src/concepts/components/__tests__/ConceptLinksManagement.spec.js +60 -12
- package/src/concepts/components/__tests__/Concepts.spec.js +66 -11
- package/src/concepts/components/__tests__/ConceptsActions.spec.js +47 -3
- package/src/concepts/components/__tests__/ConceptsBulkUpdate.spec.js +7 -3
- package/src/concepts/components/__tests__/ConceptsLabelResults.spec.js +34 -4
- package/src/concepts/components/__tests__/ConceptsPanel.spec.js +59 -13
- package/src/concepts/components/__tests__/ConceptsTable.spec.js +53 -6
- package/src/concepts/components/__tests__/ConceptsUpdateButton.spec.js +26 -13
- package/src/concepts/components/__tests__/__snapshots__/ConceptLinksManagement.spec.js.snap +164 -8
- package/src/concepts/components/__tests__/__snapshots__/Concepts.spec.js.snap +284 -34
- package/src/concepts/components/__tests__/__snapshots__/ConceptsActions.spec.js.snap +1 -1
- package/src/concepts/components/__tests__/__snapshots__/ConceptsPanel.spec.js.snap +125 -2
- package/src/concepts/components/__tests__/__snapshots__/ConceptsTable.spec.js.snap +28 -44
- package/src/concepts/components/__tests__/__snapshots__/ConceptsUpdateButton.spec.js.snap +10 -47
- package/src/concepts/hooks/useConcepts.js +34 -0
- package/src/concepts/reducers/bulkUpdateQueryInfo.js +12 -0
- package/src/concepts/reducers/index.js +2 -26
- package/src/concepts/relations/components/ConceptRelationsRoutes.js +39 -35
- package/src/concepts/relations/components/ConceptSelector.js +37 -31
- package/src/concepts/relations/components/__tests__/ConceptRelationForm.spec.js +63 -23
- package/src/concepts/relations/components/__tests__/ConceptSelector.spec.js +74 -41
- package/src/concepts/relations/components/__tests__/ConceptSelector2.spec.js +72 -0
- package/src/concepts/relations/components/__tests__/__snapshots__/ConceptRelationForm.spec.js.snap +44 -8
- package/src/concepts/relations/components/__tests__/__snapshots__/ConceptSelector.spec.js.snap +44 -27
- package/src/concepts/routines.js +2 -29
- package/src/concepts/sagas/__tests__/bulkUpdate.spec.js +6 -10
- package/src/concepts/sagas/__tests__/downloadConcepts.spec.js +4 -8
- package/src/concepts/sagas/bulkUpdate.js +6 -5
- package/src/concepts/sagas/downloadConcepts.js +3 -4
- package/src/concepts/sagas/index.js +2 -17
- package/src/concepts/selectors/getConceptColumns.js +12 -21
- package/src/concepts/selectors/index.js +1 -7
- package/src/concepts/utils/filterOptions.js +6 -5
- package/src/concepts/components/ConceptFilters.js +0 -20
- package/src/concepts/components/ConceptFiltersLoader.js +0 -27
- package/src/concepts/components/ConceptSelectedFilters.js +0 -29
- package/src/concepts/components/ConceptSelectedFiltersDefault.js +0 -42
- package/src/concepts/components/ConceptSelectedFiltersPending.js +0 -41
- package/src/concepts/components/ConceptSelectedFiltersPublished.js +0 -73
- package/src/concepts/components/ConceptUserFiltersLoader.js +0 -27
- package/src/concepts/components/ConceptsLoader.js +0 -38
- package/src/concepts/components/ConceptsSearch.js +0 -32
- package/src/concepts/components/__tests__/ConceptFilters.spec.js +0 -19
- package/src/concepts/components/__tests__/ConceptSelectedFilters.spec.js +0 -10
- package/src/concepts/components/__tests__/ConceptUserFiltersLoader.spec.js +0 -27
- package/src/concepts/components/__tests__/ConceptsLoader.spec.js +0 -34
- package/src/concepts/components/__tests__/__snapshots__/ConceptFilters.spec.js.snap +0 -47
- package/src/concepts/components/__tests__/__snapshots__/ConceptSelectedFilters.spec.js.snap +0 -9
- package/src/concepts/components/__tests__/__snapshots__/ConceptUserFiltersLoader.spec.js.snap +0 -3
- package/src/concepts/reducers/__tests__/conceptActiveFilters.spec.js +0 -83
- package/src/concepts/reducers/__tests__/conceptCount.spec.js +0 -33
- package/src/concepts/reducers/__tests__/conceptFilters.spec.js +0 -49
- package/src/concepts/reducers/__tests__/conceptFiltersLoading.spec.js +0 -28
- package/src/concepts/reducers/__tests__/conceptQuery.spec.js +0 -75
- package/src/concepts/reducers/__tests__/conceptSelectedFilter.spec.js +0 -66
- package/src/concepts/reducers/__tests__/conceptSelectedUserFilter.spec.js +0 -53
- package/src/concepts/reducers/__tests__/conceptUserFilters.spec.js +0 -76
- package/src/concepts/reducers/__tests__/concepts.spec.js +0 -40
- package/src/concepts/reducers/__tests__/conceptsActions.spec.js +0 -38
- package/src/concepts/reducers/__tests__/conceptsLoading.spec.js +0 -32
- package/src/concepts/reducers/__tests__/conceptsPageSize.spec.js +0 -33
- package/src/concepts/reducers/__tests__/previousConceptQuery.spec.js +0 -23
- package/src/concepts/reducers/conceptActiveFilters.js +0 -58
- package/src/concepts/reducers/conceptCount.js +0 -20
- package/src/concepts/reducers/conceptFilters.js +0 -21
- package/src/concepts/reducers/conceptFiltersLoading.js +0 -14
- package/src/concepts/reducers/conceptQuery.js +0 -60
- package/src/concepts/reducers/conceptSelectedFilter.js +0 -34
- package/src/concepts/reducers/conceptSelectedUserFilter.js +0 -31
- package/src/concepts/reducers/conceptUserFilters.js +0 -36
- package/src/concepts/reducers/concepts.js +0 -21
- package/src/concepts/reducers/conceptsActions.js +0 -24
- package/src/concepts/reducers/conceptsLoading.js +0 -16
- package/src/concepts/reducers/conceptsPageSize.js +0 -16
- package/src/concepts/reducers/previousConceptQuery.js +0 -15
- package/src/concepts/sagas/__tests__/deleteConceptUserFilter.spec.js +0 -75
- package/src/concepts/sagas/__tests__/fetchConceptUserFilters.spec.js +0 -70
- package/src/concepts/sagas/__tests__/fetchConcepts.spec.js +0 -87
- package/src/concepts/sagas/__tests__/saveConceptFilters.spec.js +0 -78
- package/src/concepts/sagas/deleteConceptUserFilter.js +0 -34
- package/src/concepts/sagas/fecthConceptUserFilters.js +0 -30
- package/src/concepts/sagas/fetchConceptFilters.js +0 -29
- package/src/concepts/sagas/fetchConcepts.js +0 -27
- package/src/concepts/sagas/saveConceptFilters.js +0 -30
- package/src/concepts/selectors/__tests__/getConceptAvailableFilters.spec.js +0 -16
- package/src/concepts/selectors/__tests__/getConceptFilterTypes.spec.js +0 -19
- package/src/concepts/selectors/__tests__/getConceptSelectedFilterActiveValues.spec.js +0 -16
- package/src/concepts/selectors/__tests__/getConceptSelectedFilterValues.spec.js +0 -15
- package/src/concepts/selectors/__tests__/getConceptSelectedFilters.spec.js +0 -15
- package/src/concepts/selectors/__tests__/mapSelectedFilterStateToPropsByStatus.spec.js +0 -37
- package/src/concepts/selectors/getConceptAvailableFilters.js +0 -15
- package/src/concepts/selectors/getConceptFilterTypes.js +0 -7
- package/src/concepts/selectors/getConceptSelectedFilterActiveValues.js +0 -9
- package/src/concepts/selectors/getConceptSelectedFilterValues.js +0 -12
- package/src/concepts/selectors/getConceptSelectedFilters.js +0 -7
- package/src/concepts/selectors/getPreviousConceptQuery.js +0 -1
- package/src/concepts/selectors/mapSelectedFilterStateToPropsByStatus.js +0 -47
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { initialState } from "../conceptActiveFilters";
|
|
2
|
-
import { fetchDomain } from "../../../taxonomy/routines";
|
|
3
|
-
import {
|
|
4
|
-
addConceptFilter,
|
|
5
|
-
applyConceptUserFilter,
|
|
6
|
-
closeConceptFilter,
|
|
7
|
-
removeConceptFilter,
|
|
8
|
-
resetConceptFilters,
|
|
9
|
-
toggleConceptFilterValue,
|
|
10
|
-
} from "../../routines";
|
|
11
|
-
import { conceptActiveFilters } from "..";
|
|
12
|
-
|
|
13
|
-
const fooState = { foo: "bar" };
|
|
14
|
-
|
|
15
|
-
describe("reducers: conceptActiveFilters", () => {
|
|
16
|
-
it("should provide the initial state", () => {
|
|
17
|
-
expect(conceptActiveFilters(undefined, {})).toEqual(initialState);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it("should handle the addConceptFilter.TRIGGER action", () => {
|
|
21
|
-
const filter = "baz";
|
|
22
|
-
const payload = { filter };
|
|
23
|
-
expect(conceptActiveFilters(fooState, addConceptFilter(payload))).toEqual({
|
|
24
|
-
...fooState,
|
|
25
|
-
baz: [],
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it("should handle the applyConceptUserFilter.TRIGGER action", () => {
|
|
30
|
-
const filters = { country: ["Sp"] };
|
|
31
|
-
const payload = { userFilter: { filters } };
|
|
32
|
-
expect(
|
|
33
|
-
conceptActiveFilters(fooState, applyConceptUserFilter(payload))
|
|
34
|
-
).toEqual({ ...filters });
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it("should handle the closeConceptFilter.TRIGGER action", () => {
|
|
38
|
-
const foo = ["foo1"];
|
|
39
|
-
const bar = [];
|
|
40
|
-
const state = { foo, bar };
|
|
41
|
-
const payload = { filter: "bar" };
|
|
42
|
-
expect(conceptActiveFilters(state, closeConceptFilter(payload))).toEqual({
|
|
43
|
-
foo,
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it("should handle the removeConceptFilter.TRIGGER action", () => {
|
|
48
|
-
const foo = ["foo1"];
|
|
49
|
-
const bar = [];
|
|
50
|
-
const state = { foo, bar };
|
|
51
|
-
const payload = { filter: "foo" };
|
|
52
|
-
expect(conceptActiveFilters(state, removeConceptFilter(payload))).toEqual({
|
|
53
|
-
bar,
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it("should handle the resetConceptFilters.TRIGGER action", () => {
|
|
58
|
-
expect(conceptActiveFilters(fooState, resetConceptFilters())).toEqual(
|
|
59
|
-
initialState
|
|
60
|
-
);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it("should handle the toggleConceptFilterValue.TRIGGER action", () => {
|
|
64
|
-
const foo = ["foo1", "foo2", "foo3"];
|
|
65
|
-
const bar = [];
|
|
66
|
-
const state = { foo, bar };
|
|
67
|
-
const payload = { filter: "foo", value: "foo2" };
|
|
68
|
-
expect(
|
|
69
|
-
conceptActiveFilters(state, toggleConceptFilterValue(payload))
|
|
70
|
-
).toEqual({ foo: ["foo1", "foo3"], bar });
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it("should omit the taxonomy filter on fetchDomain.TRIGGER", () => {
|
|
74
|
-
const state = { taxonomy: ["foo"], foo: ["bar"] };
|
|
75
|
-
expect(conceptActiveFilters(state, fetchDomain())).toEqual({
|
|
76
|
-
foo: ["bar"],
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it("should ignore unknown actions", () => {
|
|
81
|
-
expect(conceptActiveFilters(fooState, { type: "FOO" })).toBe(fooState);
|
|
82
|
-
});
|
|
83
|
-
});
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { clearConcepts, fetchConcepts } from "../../routines";
|
|
2
|
-
import { conceptCount } from "..";
|
|
3
|
-
|
|
4
|
-
const fooState = { foo: "bar" };
|
|
5
|
-
|
|
6
|
-
describe("reducers: conceptCount", () => {
|
|
7
|
-
const initialState = 0;
|
|
8
|
-
|
|
9
|
-
it("should provide the initial state", () => {
|
|
10
|
-
expect(conceptCount(undefined, {})).toEqual(initialState);
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it("should handle the clearConcepts.TRIGGER action", () => {
|
|
14
|
-
expect(conceptCount(fooState, { type: clearConcepts.TRIGGER })).toEqual(
|
|
15
|
-
initialState
|
|
16
|
-
);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it("should handle the fetchConcepts.SUCCESS action", () => {
|
|
20
|
-
const count = 123;
|
|
21
|
-
const headers = { "x-total-count": `${count}` };
|
|
22
|
-
expect(
|
|
23
|
-
conceptCount(fooState, {
|
|
24
|
-
type: fetchConcepts.SUCCESS,
|
|
25
|
-
payload: { headers }
|
|
26
|
-
})
|
|
27
|
-
).toEqual(count);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it("should ignore unknown actions", () => {
|
|
31
|
-
expect(conceptCount(fooState, { type: "FOO" })).toBe(fooState);
|
|
32
|
-
});
|
|
33
|
-
});
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import _ from "lodash/fp";
|
|
2
|
-
import { clearConceptFilters, fetchConceptFilters } from "../../routines";
|
|
3
|
-
import { conceptFilters } from "..";
|
|
4
|
-
|
|
5
|
-
const fooState = { foo: "bar" };
|
|
6
|
-
|
|
7
|
-
describe("reducers: conceptFilters", () => {
|
|
8
|
-
const initialState = {};
|
|
9
|
-
|
|
10
|
-
it("should provide the initial state", () => {
|
|
11
|
-
expect(conceptFilters(undefined, {})).toEqual(initialState);
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it("should handle the clearConceptFilters.TRIGGER action", () => {
|
|
15
|
-
expect(
|
|
16
|
-
conceptFilters(fooState, { type: clearConceptFilters.TRIGGER })
|
|
17
|
-
).toEqual(initialState);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it("should handle the fetchConceptFilters.SUCCESS action", () => {
|
|
21
|
-
const data = {
|
|
22
|
-
filter1: { values: ["value1", "value2"] },
|
|
23
|
-
filter2: { values: ["value1"] },
|
|
24
|
-
};
|
|
25
|
-
expect(
|
|
26
|
-
conceptFilters(fooState, {
|
|
27
|
-
type: fetchConceptFilters.SUCCESS,
|
|
28
|
-
payload: { data },
|
|
29
|
-
})
|
|
30
|
-
).toEqual(data);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it("should handle the fetchConceptFilters.SUCCESS action and omit field current", () => {
|
|
34
|
-
const data = {
|
|
35
|
-
filter1: { values: ["value1", "value2"] },
|
|
36
|
-
current: { values: ["value1"] },
|
|
37
|
-
};
|
|
38
|
-
expect(
|
|
39
|
-
conceptFilters(fooState, {
|
|
40
|
-
type: fetchConceptFilters.SUCCESS,
|
|
41
|
-
payload: { data },
|
|
42
|
-
})
|
|
43
|
-
).toEqual(_.omit(["current"])(data));
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it("should ignore unknown actions", () => {
|
|
47
|
-
expect(conceptFilters(fooState, { type: "FOO" })).toBe(fooState);
|
|
48
|
-
});
|
|
49
|
-
});
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { fetchConceptFilters } from "../../routines";
|
|
2
|
-
import { conceptFiltersLoading } from "..";
|
|
3
|
-
|
|
4
|
-
const fooState = { foo: "bar" };
|
|
5
|
-
|
|
6
|
-
describe("reducers: conceptFiltersLoading", () => {
|
|
7
|
-
const initialState = false;
|
|
8
|
-
|
|
9
|
-
it("should provide the initial state", () => {
|
|
10
|
-
expect(conceptFiltersLoading(undefined, {})).toEqual(initialState);
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it("should handle the fetchConceptFilters.REQUEST action", () => {
|
|
14
|
-
expect(
|
|
15
|
-
conceptFiltersLoading(fooState, { type: fetchConceptFilters.REQUEST })
|
|
16
|
-
).toEqual(true);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it("should handle the fetchConceptFilters.FULFILL action", () => {
|
|
20
|
-
expect(
|
|
21
|
-
conceptFiltersLoading(fooState, { type: fetchConceptFilters.FULFILL })
|
|
22
|
-
).toEqual(false);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it("should ignore unknown actions", () => {
|
|
26
|
-
expect(conceptFiltersLoading(fooState, { type: "FOO" })).toBe(fooState);
|
|
27
|
-
});
|
|
28
|
-
});
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { initialState } from "../conceptQuery";
|
|
2
|
-
import {
|
|
3
|
-
applyConceptUserFilter,
|
|
4
|
-
clearConceptFilters,
|
|
5
|
-
searchConcepts,
|
|
6
|
-
selectConceptPage
|
|
7
|
-
} from "../../routines";
|
|
8
|
-
import { conceptQuery } from "..";
|
|
9
|
-
|
|
10
|
-
const fooState = { foo: "bar" };
|
|
11
|
-
|
|
12
|
-
describe("reducers: conceptQuery", () => {
|
|
13
|
-
it("should provide the initial state", () => {
|
|
14
|
-
expect(conceptQuery(undefined, {})).toEqual(initialState);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it("should handle the applyConceptUserFilter.TRIGGER action", () => {
|
|
18
|
-
const initialPage = initialState.page;
|
|
19
|
-
|
|
20
|
-
expect(
|
|
21
|
-
conceptQuery(fooState, { type: applyConceptUserFilter.TRIGGER })
|
|
22
|
-
).toEqual({ ...fooState, page: initialPage });
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it("should handle the selectConceptPage.TRIGGER action", () => {
|
|
26
|
-
const activePage = 123;
|
|
27
|
-
const payload = { activePage };
|
|
28
|
-
expect(
|
|
29
|
-
conceptQuery(fooState, { type: selectConceptPage.TRIGGER, payload })
|
|
30
|
-
).toEqual({ ...fooState, page: activePage });
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it("should handle the clearConceptFilters.TRIGGER action", () => {
|
|
34
|
-
expect(
|
|
35
|
-
conceptQuery(fooState, { type: clearConceptFilters.TRIGGER })
|
|
36
|
-
).toEqual({
|
|
37
|
-
...fooState,
|
|
38
|
-
page: 1
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
describe("action: searchConcepts.TRIGGER", () => {
|
|
43
|
-
const query = "some query";
|
|
44
|
-
it("should set the query from the payload", () => {
|
|
45
|
-
const payload = { query };
|
|
46
|
-
expect(
|
|
47
|
-
conceptQuery(fooState, { type: searchConcepts.TRIGGER, payload })
|
|
48
|
-
).toMatchObject({ query });
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it("when query is not empty it should order by relevance and name", () => {
|
|
52
|
-
const payload = { query };
|
|
53
|
-
expect(
|
|
54
|
-
conceptQuery(fooState, { type: searchConcepts.TRIGGER, payload })
|
|
55
|
-
).toMatchObject({
|
|
56
|
-
query,
|
|
57
|
-
sort: [{ _score: "desc" }, { "name.raw": "asc" }]
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it("when query is empty it should order by name", () => {
|
|
62
|
-
const payload = { query: "" };
|
|
63
|
-
expect(
|
|
64
|
-
conceptQuery(fooState, { type: searchConcepts.TRIGGER, payload })
|
|
65
|
-
).toMatchObject({
|
|
66
|
-
query: "",
|
|
67
|
-
sort: [{ "name.raw": "asc" }]
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it("should ignore unknown actions", () => {
|
|
73
|
-
expect(conceptQuery(fooState, { type: "FOO" })).toBe(fooState);
|
|
74
|
-
});
|
|
75
|
-
});
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { initialState } from "../conceptSelectedFilter";
|
|
2
|
-
import {
|
|
3
|
-
addConceptFilter,
|
|
4
|
-
closeConceptFilter,
|
|
5
|
-
openConceptFilter,
|
|
6
|
-
removeConceptFilter,
|
|
7
|
-
resetConceptFilters
|
|
8
|
-
} from "../../routines";
|
|
9
|
-
import { conceptSelectedFilter } from "..";
|
|
10
|
-
|
|
11
|
-
const fooState = { foo: "bar" };
|
|
12
|
-
|
|
13
|
-
describe("reducers: conceptSelectedFilter", () => {
|
|
14
|
-
it("should provide the initial state", () => {
|
|
15
|
-
expect(conceptSelectedFilter(undefined, {})).toEqual(initialState);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it("should handle the addConceptFilter.TRIGGER action", () => {
|
|
19
|
-
const filter = "baz";
|
|
20
|
-
const payload = { filter };
|
|
21
|
-
expect(
|
|
22
|
-
conceptSelectedFilter(fooState, {
|
|
23
|
-
type: addConceptFilter.TRIGGER,
|
|
24
|
-
payload
|
|
25
|
-
})
|
|
26
|
-
).toEqual(filter);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it("should handle the closeConceptFilter.TRIGGER action", () => {
|
|
30
|
-
expect(
|
|
31
|
-
conceptSelectedFilter(fooState, { type: closeConceptFilter.TRIGGER })
|
|
32
|
-
).toEqual(initialState);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it("should handle the openConceptFilter.TRIGGER action", () => {
|
|
36
|
-
const filter = "baz";
|
|
37
|
-
const payload = { filter };
|
|
38
|
-
expect(
|
|
39
|
-
conceptSelectedFilter(fooState, {
|
|
40
|
-
type: openConceptFilter.TRIGGER,
|
|
41
|
-
payload
|
|
42
|
-
})
|
|
43
|
-
).toEqual(filter);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it("should handle the removeConceptFilter.TRIGGER action", () => {
|
|
47
|
-
const filter = "baz";
|
|
48
|
-
const payload = { filter };
|
|
49
|
-
expect(
|
|
50
|
-
conceptSelectedFilter(fooState, {
|
|
51
|
-
type: removeConceptFilter.TRIGGER,
|
|
52
|
-
payload
|
|
53
|
-
})
|
|
54
|
-
).toEqual(initialState);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it("should handle the resetConceptFilters.TRIGGER action", () => {
|
|
58
|
-
expect(
|
|
59
|
-
conceptSelectedFilter(fooState, { type: resetConceptFilters.TRIGGER })
|
|
60
|
-
).toEqual(initialState);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it("should ignore unknown actions", () => {
|
|
64
|
-
expect(conceptSelectedFilter(fooState, { type: "FOO" })).toBe(fooState);
|
|
65
|
-
});
|
|
66
|
-
});
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { initialState } from "../conceptSelectedUserFilter";
|
|
2
|
-
import {
|
|
3
|
-
applyConceptUserFilter,
|
|
4
|
-
removeConceptFilter,
|
|
5
|
-
resetConceptFilters
|
|
6
|
-
} from "../../routines";
|
|
7
|
-
import { conceptSelectedUserFilter } from "..";
|
|
8
|
-
|
|
9
|
-
const fooState = { foo: "bar" };
|
|
10
|
-
|
|
11
|
-
describe("reducers: conceptActiveFilters", () => {
|
|
12
|
-
it("should provide the initial state", () => {
|
|
13
|
-
expect(conceptSelectedUserFilter(undefined, {})).toEqual(initialState);
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it("should handle the applyConceptUserFilter.TRIGGER action", () => {
|
|
17
|
-
const name = "by country";
|
|
18
|
-
const payload = { userFilter: { name } };
|
|
19
|
-
expect(
|
|
20
|
-
conceptSelectedUserFilter(fooState, {
|
|
21
|
-
type: applyConceptUserFilter.TRIGGER,
|
|
22
|
-
payload
|
|
23
|
-
})
|
|
24
|
-
).toEqual(name);
|
|
25
|
-
|
|
26
|
-
expect(
|
|
27
|
-
conceptSelectedUserFilter(name, {
|
|
28
|
-
type: applyConceptUserFilter.TRIGGER,
|
|
29
|
-
payload
|
|
30
|
-
})
|
|
31
|
-
).toEqual(null);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it("should handle the removeConceptFilter.TRIGGER action", () => {
|
|
35
|
-
expect(
|
|
36
|
-
conceptSelectedUserFilter(fooState, {
|
|
37
|
-
type: removeConceptFilter.TRIGGER
|
|
38
|
-
})
|
|
39
|
-
).toEqual(initialState);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it("should handle the resetConceptFilters.TRIGGER action", () => {
|
|
43
|
-
expect(
|
|
44
|
-
conceptSelectedUserFilter(fooState, {
|
|
45
|
-
type: resetConceptFilters.TRIGGER
|
|
46
|
-
})
|
|
47
|
-
).toEqual(initialState);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it("should ignore unknown actions", () => {
|
|
51
|
-
expect(conceptSelectedUserFilter(fooState, { type: "FOO" })).toBe(fooState);
|
|
52
|
-
});
|
|
53
|
-
});
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import _ from "lodash/fp";
|
|
2
|
-
import { accentInsensitivePathOrder } from "@truedat/core/services/sort";
|
|
3
|
-
import { initialState } from "../conceptUserFilters";
|
|
4
|
-
import {
|
|
5
|
-
fetchConceptUserFilters,
|
|
6
|
-
clearConceptUserFilters,
|
|
7
|
-
deleteConceptUserFilter,
|
|
8
|
-
saveConceptFilters
|
|
9
|
-
} from "../../routines";
|
|
10
|
-
import { conceptUserFilters } from "..";
|
|
11
|
-
|
|
12
|
-
const fooState = { foo: "bar" };
|
|
13
|
-
|
|
14
|
-
describe("reducers: conceptActiveFilters", () => {
|
|
15
|
-
it("should provide the initial state", () => {
|
|
16
|
-
expect(conceptUserFilters(undefined, {})).toEqual(initialState);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it("should handle the fetchConceptUserFilters.SUCCESS action", () => {
|
|
20
|
-
const filters = [
|
|
21
|
-
{ name: "b", id: 1, filters: { country: ["S"] } },
|
|
22
|
-
{ name: "a", id: 2, filters: { country: ["S2"] } }
|
|
23
|
-
];
|
|
24
|
-
const sortedFilters = _.sortBy(accentInsensitivePathOrder("name"))(filters);
|
|
25
|
-
expect(
|
|
26
|
-
conceptUserFilters(fooState, {
|
|
27
|
-
type: fetchConceptUserFilters.SUCCESS,
|
|
28
|
-
payload: { data: filters }
|
|
29
|
-
})
|
|
30
|
-
).toEqual(sortedFilters);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it("should handle the saveConceptFilters.SUCCESS action", () => {
|
|
34
|
-
const filters = [
|
|
35
|
-
{ name: "b", id: 1, filters: { country: ["S"] } },
|
|
36
|
-
{ name: "a", id: 2, filters: { country: ["S2"] } }
|
|
37
|
-
];
|
|
38
|
-
const newFilter = { name: "c", id: 3, filters: { country: ["S3"] } };
|
|
39
|
-
const sortedFilters = _.flow(
|
|
40
|
-
_.concat([newFilter]),
|
|
41
|
-
_.sortBy(accentInsensitivePathOrder("name"))
|
|
42
|
-
)(filters);
|
|
43
|
-
|
|
44
|
-
expect(
|
|
45
|
-
conceptUserFilters(filters, {
|
|
46
|
-
type: saveConceptFilters.SUCCESS,
|
|
47
|
-
payload: { data: newFilter }
|
|
48
|
-
})
|
|
49
|
-
).toEqual(sortedFilters);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it("should handle the deleteConceptUserFilter.SUCCESS action", () => {
|
|
53
|
-
const filters = [
|
|
54
|
-
{ name: "b", id: 1, filters: { country: ["S"] } },
|
|
55
|
-
{ name: "a", id: 2, filters: { country: ["S2"] } }
|
|
56
|
-
];
|
|
57
|
-
expect(
|
|
58
|
-
conceptUserFilters(filters, {
|
|
59
|
-
type: deleteConceptUserFilter.SUCCESS,
|
|
60
|
-
meta: { id: 1 }
|
|
61
|
-
})
|
|
62
|
-
).toEqual([{ name: "a", id: 2, filters: { country: ["S2"] } }]);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it("should handle the clearConceptUserFilters.TRIGGER action", () => {
|
|
66
|
-
expect(
|
|
67
|
-
conceptUserFilters(fooState, {
|
|
68
|
-
type: clearConceptUserFilters.TRIGGER
|
|
69
|
-
})
|
|
70
|
-
).toEqual(initialState);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it("should ignore unknown actions", () => {
|
|
74
|
-
expect(conceptUserFilters(fooState, { type: "FOO" })).toBe(fooState);
|
|
75
|
-
});
|
|
76
|
-
});
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { clearConcepts, fetchConcepts } from "../../routines";
|
|
2
|
-
import { concepts } from "..";
|
|
3
|
-
|
|
4
|
-
const fooState = { foo: "bar" };
|
|
5
|
-
|
|
6
|
-
describe("reducers: concept", () => {
|
|
7
|
-
const initialState = [];
|
|
8
|
-
|
|
9
|
-
it("should provide the initial state", () => {
|
|
10
|
-
expect(concepts(undefined, {})).toEqual(initialState);
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it("should handle the clearConcepts.TRIGGER action", () => {
|
|
14
|
-
expect(concepts(fooState, { type: clearConcepts.TRIGGER })).toEqual(
|
|
15
|
-
initialState
|
|
16
|
-
);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it("should handle the fetchConcepts.FAILURE action", () => {
|
|
20
|
-
expect(concepts(fooState, { type: fetchConcepts.FAILURE })).toEqual(
|
|
21
|
-
initialState
|
|
22
|
-
);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it("should handle the fetchConcepts.SUCCESS action", () => {
|
|
26
|
-
const collection = [{ id: 1, name: "Concept 1", business_concept_id: 4 }];
|
|
27
|
-
const data = { data: collection };
|
|
28
|
-
const headers = { "x-total-count": "123" };
|
|
29
|
-
expect(
|
|
30
|
-
concepts(fooState, {
|
|
31
|
-
type: fetchConcepts.SUCCESS,
|
|
32
|
-
payload: { data, headers }
|
|
33
|
-
})
|
|
34
|
-
).toEqual(collection);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it("should ignore unknown actions", () => {
|
|
38
|
-
expect(concepts(fooState, { type: "FOO" })).toBe(fooState);
|
|
39
|
-
});
|
|
40
|
-
});
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { fetchConcepts } from "../../routines";
|
|
2
|
-
import { conceptsActions } from "..";
|
|
3
|
-
|
|
4
|
-
const fooState = { foo: "bar" };
|
|
5
|
-
const payload = {};
|
|
6
|
-
|
|
7
|
-
describe("reducers: conceptsActions", () => {
|
|
8
|
-
it("should provide the initial state", () => {
|
|
9
|
-
expect(conceptsActions(undefined, {})).toEqual({});
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it("should be an empty object after receiving the fetchConcepts.REQUEST action", () => {
|
|
13
|
-
expect(
|
|
14
|
-
conceptsActions(fooState, { type: fetchConcepts.REQUEST, payload })
|
|
15
|
-
).toEqual({});
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it("should extract _actions from the fetchConcepts.SUCCESS action", () => {
|
|
19
|
-
const _actions = { delete: { foo: "bar" } };
|
|
20
|
-
const data = { _actions };
|
|
21
|
-
const payload = { data };
|
|
22
|
-
expect(
|
|
23
|
-
conceptsActions(fooState, { type: fetchConcepts.SUCCESS, payload })
|
|
24
|
-
).toMatchObject(_actions);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it("should be an empty object after receiving the fetchConcepts.SUCCESS action without _actions", () => {
|
|
28
|
-
const data = [{ id: 1 }];
|
|
29
|
-
const payload = { data };
|
|
30
|
-
expect(
|
|
31
|
-
conceptsActions(fooState, { type: fetchConcepts.SUCCESS, payload })
|
|
32
|
-
).toEqual({});
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it("should ignore unhandled actions", () => {
|
|
36
|
-
expect(conceptsActions(fooState, { type: "FOO" })).toBe(fooState);
|
|
37
|
-
});
|
|
38
|
-
});
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { fetchConcepts } from "../../routines";
|
|
2
|
-
import { conceptsLoading } from "..";
|
|
3
|
-
|
|
4
|
-
const fooState = { foo: "bar" };
|
|
5
|
-
|
|
6
|
-
describe("reducers: conceptsLoading", () => {
|
|
7
|
-
it("should provide the initial state", () => {
|
|
8
|
-
expect(conceptsLoading(undefined, {})).toBe(false);
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
it("should be true after receiving the fetchConcepts.REQUEST action", () => {
|
|
12
|
-
expect(conceptsLoading(fooState, { type: fetchConcepts.REQUEST })).toBe(
|
|
13
|
-
true
|
|
14
|
-
);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it("should be false after receiving the fetchConcepts.SUCCESS action", () => {
|
|
18
|
-
expect(conceptsLoading(fooState, { type: fetchConcepts.SUCCESS })).toBe(
|
|
19
|
-
false
|
|
20
|
-
);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it("should be false after receiving the fetchConcepts.FAILURE action", () => {
|
|
24
|
-
expect(conceptsLoading(fooState, { type: fetchConcepts.FAILURE })).toBe(
|
|
25
|
-
false
|
|
26
|
-
);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it("should ignore unhandled actions", () => {
|
|
30
|
-
expect(conceptsLoading(fooState, { type: "FOO" })).toBe(fooState);
|
|
31
|
-
});
|
|
32
|
-
});
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { fetchConcepts } from "../../routines";
|
|
2
|
-
import { conceptsPageSize } from "..";
|
|
3
|
-
|
|
4
|
-
const fooState = { foo: "bar" };
|
|
5
|
-
const initialState = 20;
|
|
6
|
-
|
|
7
|
-
describe("reducers: conceptsPageSize", () => {
|
|
8
|
-
it("should provide the initial state", () => {
|
|
9
|
-
expect(conceptsPageSize(undefined, {})).toEqual(initialState);
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
describe("action: fetchConcepts.TRIGGER", () => {
|
|
13
|
-
describe("with an empty payload", () => {
|
|
14
|
-
it("should return the passed state if no size is specified", () => {
|
|
15
|
-
const payload = {};
|
|
16
|
-
expect(
|
|
17
|
-
conceptsPageSize(fooState, { type: fetchConcepts.TRIGGER, payload })
|
|
18
|
-
).toEqual(fooState);
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it("should set size value if specified", () => {
|
|
23
|
-
const size = 1234;
|
|
24
|
-
|
|
25
|
-
expect(
|
|
26
|
-
conceptsPageSize(fooState, {
|
|
27
|
-
type: fetchConcepts.TRIGGER,
|
|
28
|
-
payload: { size }
|
|
29
|
-
})
|
|
30
|
-
).toBe(1234);
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
});
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { fetchConcepts } from "../../routines";
|
|
2
|
-
import { previousConceptQuery } from "..";
|
|
3
|
-
|
|
4
|
-
const fooState = { foo: "bar" };
|
|
5
|
-
const initialState = {};
|
|
6
|
-
|
|
7
|
-
describe("reducers: previousConceptQuery", () => {
|
|
8
|
-
it("should provide the initial state", () => {
|
|
9
|
-
expect((undefined, {})).toEqual(initialState);
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it("should handle the fetchConcepts.TRIGGER action", () => {
|
|
13
|
-
const payload = {
|
|
14
|
-
filters: { status: ["published"] },
|
|
15
|
-
page: 0,
|
|
16
|
-
size: 20,
|
|
17
|
-
query: "some quey"
|
|
18
|
-
};
|
|
19
|
-
expect(
|
|
20
|
-
previousConceptQuery(fooState, { type: fetchConcepts.TRIGGER, payload })
|
|
21
|
-
).toEqual(payload);
|
|
22
|
-
});
|
|
23
|
-
});
|