@eox/itemfilter 0.8.3 → 0.8.5

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eox/itemfilter",
3
- "version": "0.8.3",
3
+ "version": "0.8.5",
4
4
  "type": "module",
5
5
  "devDependencies": {
6
6
  "@eox/eslint-config": "^1.0.0",
@@ -137,4 +137,40 @@ describe("Item Filter Config", () => {
137
137
  // });
138
138
  // });
139
139
  // });
140
+
141
+ it('should allow only one accordion of each type to be open at a time if configured', () => {
142
+ cy.get("eox-itemfilter").then(($el) => {
143
+ (<EOxItemFilter>$el[0]).config.expandMultipleFilters = false;
144
+ (<EOxItemFilter>$el[0]).config.expandMultipleResults = false;
145
+ });
146
+
147
+ const checkExclusiveOpen = (selector: string, isSubcomponent = false) => {
148
+ cy.get("eox-itemfilter").shadow().within(() => {
149
+ cy.get(selector).then(accordions => {
150
+ for (let i = 0; i < accordions.length; i++) {
151
+ const accordionToClick = isSubcomponent
152
+ ? cy.get(selector).eq(i).find('eox-itemfilter-expandcontainer').shadow().find('details')
153
+ : cy.get(selector).eq(i).find('details');
154
+
155
+ accordionToClick.click({ multiple: true, force: true });
156
+ accordionToClick.should('have.attr', 'open');
157
+
158
+ // Check that all other accordions are closed
159
+ for (let j = 0; j < accordions.length; j++) {
160
+ if (i !== j) {
161
+ const accordionToCheck = isSubcomponent
162
+ ? cy.get(selector).eq(j).find('eox-itemfilter-expandcontainer').shadow().find('details')
163
+ : cy.get(selector).eq(j).find('details');
164
+
165
+ accordionToCheck.should('not.have.attr', 'open');
166
+ }
167
+ }
168
+ }
169
+ });
170
+ });
171
+ }
172
+
173
+ checkExclusiveOpen('ul#filters', true);
174
+ checkExclusiveOpen('ul#results');
175
+ });
140
176
  });