@projectcaluma/ember-testing 11.0.0-beta.8 → 11.0.0-beta.9

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/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ # [@projectcaluma/ember-testing-v11.0.0-beta.9](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-testing-v11.0.0-beta.8...@projectcaluma/ember-testing-v11.0.0-beta.9) (2022-06-09)
2
+
3
+
4
+ ### Features
5
+
6
+ * **caluma:** use new filter syntax of caluma ([7a00c03](https://github.com/projectcaluma/ember-caluma/commit/7a00c03a103933d9e48dd88adb7382441a298742))
7
+
8
+
9
+ ### BREAKING CHANGES
10
+
11
+ * **caluma:** `ember-caluma` now requires Caluma version >=
12
+ 8.0.0-beta.6
13
+
1
14
  # [@projectcaluma/ember-testing-v11.0.0-beta.8](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-testing-v11.0.0-beta.7...@projectcaluma/ember-testing-v11.0.0-beta.8) (2022-05-13)
2
15
 
3
16
 
@@ -6,25 +6,18 @@ export default class BaseFilter {
6
6
  }
7
7
 
8
8
  _getFilterFns(rawFilters) {
9
- const filters = Array.isArray(rawFilters)
10
- ? // new format
11
- rawFilters
12
- .filter((filter) => Object.keys(filter).length !== 0) // filter out empty filters
13
- .map((filter) => {
14
- const entries = Object.entries(filter);
15
- const key = entries[0][0];
16
- const value = entries[0][1];
17
- const options = entries
18
- .slice(1)
19
- .reduce((opts, [k, v]) => ({ ...opts, [k]: v }), {});
9
+ const filters = rawFilters
10
+ .filter((filter) => Object.keys(filter).length !== 0) // filter out empty filters
11
+ .map((filter) => {
12
+ const entries = Object.entries(filter);
13
+ const key = entries[0][0];
14
+ const value = entries[0][1];
15
+ const options = entries
16
+ .slice(1)
17
+ .reduce((opts, [k, v]) => ({ ...opts, [k]: v }), {});
20
18
 
21
- return { key, value, options };
22
- })
23
- : // old format
24
- Object.entries(rawFilters).map(([key, value]) => ({
25
- key,
26
- value,
27
- }));
19
+ return { key, value, options };
20
+ });
28
21
 
29
22
  return filters.map(({ key, value, options = {} }) => {
30
23
  const fn = this[key];
@@ -53,7 +46,7 @@ export default class BaseFilter {
53
46
  }
54
47
 
55
48
  filter(records, filters) {
56
- return this._getFilterFns(filters?.filter ?? filters ?? []).reduce(
49
+ return this._getFilterFns(filters?.filter ?? []).reduce(
57
50
  (recs, fn) => fn(recs),
58
51
  this.sort(records, filters?.order)
59
52
  );
@@ -64,7 +57,11 @@ export default class BaseFilter {
64
57
  }
65
58
 
66
59
  slug(records, value) {
67
- return records.filter(({ slug }) => slug === value);
60
+ return this.slugs(records, [value]);
61
+ }
62
+
63
+ slugs(records, values) {
64
+ return records.filter(({ slug }) => values.includes(slug));
68
65
  }
69
66
 
70
67
  id(records, value) {