@eox/itemfilter 0.14.2-dev.1721300053.0 → 0.14.2-dev.1721328490.0
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/dist/eox-itemfilter.js +529 -520
- package/dist/eox-itemfilter.umd.cjs +65 -58
- package/package.json +1 -1
- package/test/cases/filters/filter-keys.js +22 -0
- package/test/cases/filters/index.js +3 -0
- package/test/filters.cy.js +56 -0
package/package.json
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests the `filterKeys` options within the `filterObject`.
|
|
3
|
+
* It verifies that the `filterKeys` override the normally rendered filter keys.
|
|
4
|
+
*
|
|
5
|
+
* @param {Array} filterKeys - An array including the custom filter keys.
|
|
6
|
+
*/
|
|
7
|
+
const filterKeysTest = (filterKeys) => {
|
|
8
|
+
cy.get("eox-itemfilter")
|
|
9
|
+
.shadow()
|
|
10
|
+
.within(() => {
|
|
11
|
+
cy.get("eox-itemfilter-select")
|
|
12
|
+
.should("be.visible")
|
|
13
|
+
.shadow()
|
|
14
|
+
.within(($el) => {
|
|
15
|
+
const identifiers = $el[0].querySelectorAll("li[data-identifier");
|
|
16
|
+
expect(identifiers.length).to.eq(filterKeys.length);
|
|
17
|
+
expect(identifiers[0].dataset.identifier).to.eq(filterKeys[0]);
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default filterKeysTest;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import "../src/main";
|
|
2
|
+
import testItems from "./testItems.json";
|
|
3
|
+
import { filterkeysTest } from "./cases/filters/";
|
|
4
|
+
|
|
5
|
+
describe("Item Filter Config", () => {
|
|
6
|
+
const state = {
|
|
7
|
+
agriculture: true,
|
|
8
|
+
health: true,
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const customOrder = {
|
|
12
|
+
health: 0,
|
|
13
|
+
water: 1,
|
|
14
|
+
air: 2,
|
|
15
|
+
economy: 3,
|
|
16
|
+
agriculture: 4,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const selectedResultIndex = 1;
|
|
20
|
+
|
|
21
|
+
const filterKeys = ["foo", "bar", 0, true];
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Runs before each test case to mount the eox-itemfilter component and configure it.
|
|
25
|
+
*/
|
|
26
|
+
beforeEach(() => {
|
|
27
|
+
cy.mount(`<eox-itemfilter></eox-itemfilter>`)
|
|
28
|
+
.as("eox-itemfilter")
|
|
29
|
+
.then(($el) => {
|
|
30
|
+
const eoxItemFilter = $el[0];
|
|
31
|
+
Object.assign(eoxItemFilter, {
|
|
32
|
+
config: {
|
|
33
|
+
titleProperty: "title",
|
|
34
|
+
filterProperties: [
|
|
35
|
+
{
|
|
36
|
+
key: "themes",
|
|
37
|
+
type: "multiselect",
|
|
38
|
+
expanded: true,
|
|
39
|
+
sort: (a, b) => customOrder[a] - customOrder[b],
|
|
40
|
+
state,
|
|
41
|
+
filterKeys,
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
aggregateResults: "themes",
|
|
45
|
+
},
|
|
46
|
+
items: testItems,
|
|
47
|
+
selectedResult: testItems[selectedResultIndex],
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Test case for filterKeys
|
|
54
|
+
*/
|
|
55
|
+
it("should support setting filterKeys", () => filterkeysTest(filterKeys));
|
|
56
|
+
});
|