resourcerer 1.2.2 → 2.0.0-beta

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.
Files changed (59) hide show
  1. package/README.md +138 -164
  2. package/build/index.d.ts +9 -0
  3. package/build/index.js +9 -0
  4. package/build/lib/collection.d.ts +107 -0
  5. package/build/lib/collection.js +251 -0
  6. package/build/lib/config.d.ts +20 -0
  7. package/build/lib/config.js +23 -0
  8. package/build/lib/error-boundary.d.ts +12 -0
  9. package/build/lib/error-boundary.js +18 -0
  10. package/build/lib/events.d.ts +11 -0
  11. package/build/lib/events.js +12 -0
  12. package/build/lib/model-cache.d.ts +13 -0
  13. package/build/lib/model-cache.js +62 -0
  14. package/build/lib/model.d.ts +48 -0
  15. package/build/lib/model.js +170 -0
  16. package/build/lib/prefetch.d.ts +3 -0
  17. package/build/lib/prefetch.js +27 -0
  18. package/build/lib/request.d.ts +20 -0
  19. package/build/lib/request.js +53 -0
  20. package/build/lib/resourcerer.d.ts +13 -0
  21. package/build/lib/resourcerer.js +406 -0
  22. package/build/lib/sync.d.ts +18 -0
  23. package/build/lib/sync.js +58 -0
  24. package/build/lib/types.d.ts +66 -0
  25. package/build/lib/types.js +1 -0
  26. package/build/lib/utils.d.ts +14 -0
  27. package/build/lib/utils.js +87 -0
  28. package/docs/advanced_topics.md +9 -77
  29. package/docs/collection.md +28 -28
  30. package/docs/migrating_to_2.0.md +72 -0
  31. package/docs/model.md +21 -21
  32. package/docs/typescript.md +68 -20
  33. package/package.json +27 -30
  34. package/resourcerer.d.ts +50 -0
  35. package/test/collection.test.js +305 -316
  36. package/test/config.test.js +21 -75
  37. package/test/events.test.js +42 -41
  38. package/test/model-cache.test.js +99 -77
  39. package/test/model.test.js +204 -209
  40. package/test/prefetch.test.js +35 -61
  41. package/test/request.test.js +104 -109
  42. package/test/sync.test.js +132 -107
  43. package/test/utils.test.js +173 -159
  44. package/index.d.ts +0 -269
  45. package/index.js +0 -14
  46. package/lib/collection.js +0 -584
  47. package/lib/config.js +0 -131
  48. package/lib/constants.js +0 -6
  49. package/lib/error-boundary.js +0 -47
  50. package/lib/events.js +0 -19
  51. package/lib/model-cache.js +0 -131
  52. package/lib/model.js +0 -372
  53. package/lib/prefetch.js +0 -59
  54. package/lib/request.js +0 -126
  55. package/lib/resourcerer.js +0 -963
  56. package/lib/sync.js +0 -94
  57. package/lib/utils.js +0 -220
  58. package/test/model-mocks.js +0 -110
  59. package/test/setup.js +0 -63
@@ -1,4 +1,4 @@
1
- import {areAnyLoading, areAnyPending, haveAllLoaded, haveAnyErrored} from '../index';
1
+ import { Utils } from "../index";
2
2
  import {
3
3
  camelize,
4
4
  hasErrored,
@@ -12,148 +12,147 @@ import {
12
12
  result,
13
13
  sortBy,
14
14
  uniqueId,
15
- urlError
16
- } from '../lib/utils';
17
- // these will just test that our top-level exports are working as expected
18
- import {LoadingStates} from '../lib/constants';
19
-
20
- describe('Utils', () => {
21
- describe('hasErrored method', () => {
22
- it('returns true if any loading state has errored', () => {
23
- expect(hasErrored([LoadingStates.ERROR, LoadingStates.LOADING])).toBe(true);
24
- expect(hasErrored(LoadingStates.ERROR)).toBe(true);
25
- expect(hasErrored({myLoadingState: LoadingStates.ERROR})).toBe(true);
26
- expect(haveAnyErrored([LoadingStates.ERROR, LoadingStates.LOADING])).toBe(true);
27
- expect(haveAnyErrored(LoadingStates.ERROR)).toBe(true);
28
- expect(haveAnyErrored({myLoadingState: LoadingStates.ERROR})).toBe(true);
15
+ urlError,
16
+ } from "../lib/utils";
17
+ import { vi } from "vitest";
18
+
19
+ describe("Utils", () => {
20
+ describe("hasErrored method", () => {
21
+ it("returns true if any loading state has errored", () => {
22
+ expect(hasErrored(["error", "loading"])).toBe(true);
23
+ expect(hasErrored("error")).toBe(true);
24
+ expect(hasErrored({ myLoadingState: "error" })).toBe(true);
25
+ expect(Utils.hasErrored(["error", "loading"])).toBe(true);
26
+ expect(Utils.hasErrored("error")).toBe(true);
27
+ expect(Utils.hasErrored({ myLoadingState: "error" })).toBe(true);
29
28
  });
30
29
 
31
- it('returns false if no loading states have errored', () => {
32
- expect(hasErrored([LoadingStates.LOADED, LoadingStates.LOADING])).toBe(false);
33
- expect(hasErrored(LoadingStates.LOADED)).toBe(false);
34
- expect(hasErrored({myLoadingState: LoadingStates.LOADED})).toBe(false);
35
- expect(haveAnyErrored([LoadingStates.LOADED, LoadingStates.LOADING])).toBe(false);
36
- expect(haveAnyErrored(LoadingStates.LOADED)).toBe(false);
37
- expect(haveAnyErrored({myLoadingState: LoadingStates.LOADED})).toBe(false);
30
+ it("returns false if no loading states have errored", () => {
31
+ expect(hasErrored(["loaded", "loading"])).toBe(false);
32
+ expect(hasErrored("loaded")).toBe(false);
33
+ expect(hasErrored({ myLoadingState: "loaded" })).toBe(false);
34
+ expect(Utils.hasErrored(["loaded", "loading"])).toBe(false);
35
+ expect(Utils.hasErrored("loaded")).toBe(false);
36
+ expect(Utils.hasErrored({ myLoadingState: "loaded" })).toBe(false);
38
37
  });
39
38
 
40
- it('returns false if an undefined loading state is passed', () => {
39
+ it("returns false if an undefined loading state is passed", () => {
41
40
  expect(hasErrored(undefined)).toBe(false);
42
- expect(haveAnyErrored(undefined)).toBe(false);
41
+ expect(Utils.hasErrored(undefined)).toBe(false);
43
42
  });
44
43
  });
45
44
 
46
- describe('isLoading method', () => {
47
- it('returns true if any loading state is loading', () => {
48
- expect(isLoading([LoadingStates.ERROR, LoadingStates.LOADING])).toBe(true);
49
- expect(isLoading(LoadingStates.LOADING)).toBe(true);
50
- expect(isLoading({myLoadingState: LoadingStates.LOADING})).toBe(true);
51
- expect(areAnyLoading([LoadingStates.ERROR, LoadingStates.LOADING])).toBe(true);
52
- expect(areAnyLoading(LoadingStates.LOADING)).toBe(true);
53
- expect(areAnyLoading({myLoadingState: LoadingStates.LOADING})).toBe(true);
45
+ describe("isLoading method", () => {
46
+ it("returns true if any loading state is loading", () => {
47
+ expect(isLoading(["error", "loading"])).toBe(true);
48
+ expect(isLoading("loading")).toBe(true);
49
+ expect(isLoading({ myLoadingState: "loading" })).toBe(true);
50
+ expect(Utils.isLoading(["error", "loading"])).toBe(true);
51
+ expect(Utils.isLoading("loading")).toBe(true);
52
+ expect(Utils.isLoading({ myLoadingState: "loading" })).toBe(true);
54
53
  });
55
54
 
56
- it('returns false if no loading states are loading', () => {
57
- expect(isLoading([LoadingStates.LOADED, LoadingStates.LOADED])).toBe(false);
58
- expect(isLoading(LoadingStates.LOADED)).toBe(false);
59
- expect(isLoading({myLoadingState: LoadingStates.LOADED})).toBe(false);
60
- expect(areAnyLoading([LoadingStates.LOADED, LoadingStates.LOADED])).toBe(false);
61
- expect(areAnyLoading(LoadingStates.LOADED)).toBe(false);
62
- expect(areAnyLoading({myLoadingState: LoadingStates.LOADED})).toBe(false);
55
+ it("returns false if no loading states are loading", () => {
56
+ expect(isLoading(["loaded", "loaded"])).toBe(false);
57
+ expect(isLoading("loaded")).toBe(false);
58
+ expect(isLoading({ myLoadingState: "loaded" })).toBe(false);
59
+ expect(Utils.isLoading(["loaded", "loaded"])).toBe(false);
60
+ expect(Utils.isLoading("loaded")).toBe(false);
61
+ expect(Utils.isLoading({ myLoadingState: "loaded" })).toBe(false);
63
62
  });
64
63
 
65
- it('returns false if an undefined loading state is passed', () => {
64
+ it("returns false if an undefined loading state is passed", () => {
66
65
  expect(isLoading(undefined)).toBe(false);
67
- expect(areAnyLoading(undefined)).toBe(false);
66
+ expect(Utils.isLoading(undefined)).toBe(false);
68
67
  });
69
68
  });
70
69
 
71
- describe('hasLoaded method', () => {
72
- it('returns true if all loading states have loaded', () => {
73
- expect(hasLoaded([LoadingStates.LOADED, LoadingStates.LOADED])).toBe(true);
74
- expect(hasLoaded(LoadingStates.LOADED)).toBe(true);
75
- expect(hasLoaded({myLoadingState: LoadingStates.LOADED})).toBe(true);
76
- expect(haveAllLoaded([LoadingStates.LOADED, LoadingStates.LOADED])).toBe(true);
77
- expect(haveAllLoaded(LoadingStates.LOADED)).toBe(true);
78
- expect(haveAllLoaded({myLoadingState: LoadingStates.LOADED})).toBe(true);
70
+ describe("hasLoaded method", () => {
71
+ it("returns true if all loading states have loaded", () => {
72
+ expect(hasLoaded(["loaded", "loaded"])).toBe(true);
73
+ expect(hasLoaded("loaded")).toBe(true);
74
+ expect(hasLoaded({ myLoadingState: "loaded" })).toBe(true);
75
+ expect(Utils.hasLoaded(["loaded", "loaded"])).toBe(true);
76
+ expect(Utils.hasLoaded("loaded")).toBe(true);
77
+ expect(Utils.hasLoaded({ myLoadingState: "loaded" })).toBe(true);
79
78
  });
80
79
 
81
- it('returns false if any state has not loaded', () => {
82
- expect(hasLoaded([LoadingStates.ERROR, LoadingStates.LOADED])).toBe(false);
83
- expect(hasLoaded([LoadingStates.LOADED, LoadingStates.LOADING])).toBe(false);
84
- expect(hasLoaded(LoadingStates.LOADING)).toBe(false);
85
- expect(hasLoaded({myLoadingState: LoadingStates.LOADING})).toBe(false);
86
- expect(haveAllLoaded([LoadingStates.ERROR, LoadingStates.LOADED])).toBe(false);
87
- expect(haveAllLoaded([LoadingStates.LOADED, LoadingStates.LOADING])).toBe(false);
88
- expect(haveAllLoaded(LoadingStates.LOADING)).toBe(false);
89
- expect(haveAllLoaded({myLoadingState: LoadingStates.LOADING})).toBe(false);
80
+ it("returns false if any state has not loaded", () => {
81
+ expect(hasLoaded(["error", "loaded"])).toBe(false);
82
+ expect(hasLoaded(["loaded", "loading"])).toBe(false);
83
+ expect(hasLoaded("loading")).toBe(false);
84
+ expect(hasLoaded({ myLoadingState: "loading" })).toBe(false);
85
+ expect(Utils.hasLoaded(["error", "loaded"])).toBe(false);
86
+ expect(Utils.hasLoaded(["loaded", "loading"])).toBe(false);
87
+ expect(Utils.hasLoaded("loading")).toBe(false);
88
+ expect(Utils.hasLoaded({ myLoadingState: "loading" })).toBe(false);
90
89
  });
91
90
 
92
- it('returns false if an undefined loading state is passed', () => {
91
+ it("returns false if an undefined loading state is passed", () => {
93
92
  expect(hasLoaded(undefined)).toBe(false);
94
- expect(haveAllLoaded(undefined)).toBe(false);
93
+ expect(Utils.hasLoaded(undefined)).toBe(false);
95
94
  });
96
95
  });
97
96
 
98
- describe('isPending method', () => {
99
- it('returns true if any loading state is pending', () => {
100
- expect(isPending([LoadingStates.PENDING, LoadingStates.LOADING])).toBe(true);
101
- expect(isPending(LoadingStates.PENDING)).toBe(true);
102
- expect(isPending({myLoadingState: LoadingStates.PENDING})).toBe(true);
103
- expect(areAnyPending([LoadingStates.PENDING, LoadingStates.LOADING])).toBe(true);
104
- expect(areAnyPending(LoadingStates.PENDING)).toBe(true);
105
- expect(areAnyPending({myLoadingState: LoadingStates.PENDING})).toBe(true);
97
+ describe("isPending method", () => {
98
+ it("returns true if any loading state is pending", () => {
99
+ expect(isPending(["pending", "loading"])).toBe(true);
100
+ expect(isPending("pending")).toBe(true);
101
+ expect(isPending({ myLoadingState: "pending" })).toBe(true);
102
+ expect(Utils.isPending(["pending", "loading"])).toBe(true);
103
+ expect(Utils.isPending("pending")).toBe(true);
104
+ expect(Utils.isPending({ myLoadingState: "pending" })).toBe(true);
106
105
  });
107
106
 
108
- it('returns false if no loading states are pending', () => {
109
- expect(isPending([LoadingStates.LOADED, LoadingStates.LOADING])).toBe(false);
110
- expect(isPending(LoadingStates.LOADED)).toBe(false);
111
- expect(isPending({myLoadingState: LoadingStates.LOADED})).toBe(false);
112
- expect(areAnyPending([LoadingStates.LOADED, LoadingStates.LOADING])).toBe(false);
113
- expect(areAnyPending(LoadingStates.LOADED)).toBe(false);
114
- expect(areAnyPending({myLoadingState: LoadingStates.LOADED})).toBe(false);
107
+ it("returns false if no loading states are pending", () => {
108
+ expect(isPending(["loaded", "loading"])).toBe(false);
109
+ expect(isPending("loaded")).toBe(false);
110
+ expect(isPending({ myLoadingState: "loaded" })).toBe(false);
111
+ expect(Utils.isPending(["loaded", "loading"])).toBe(false);
112
+ expect(Utils.isPending("loaded")).toBe(false);
113
+ expect(Utils.isPending({ myLoadingState: "loaded" })).toBe(false);
115
114
  });
116
115
 
117
- it('returns false if an undefined loading state is passed', () => {
116
+ it("returns false if an undefined loading state is passed", () => {
118
117
  expect(isPending(undefined)).toBe(false);
119
- expect(areAnyPending(undefined)).toBe(false);
118
+ expect(Utils.isPending(undefined)).toBe(false);
120
119
  });
121
120
  });
122
121
 
123
- describe('camelize', () => {
124
- it('passes words that are already camelCase', () => {
125
- expect(camelize('camelCase')).toEqual('camelCase');
122
+ describe("camelize", () => {
123
+ it("passes words that are already camelCase", () => {
124
+ expect(camelize("camelCase")).toEqual("camelCase");
126
125
  // also leaves alone PascalCase
127
- expect(camelize('PascalCase')).toEqual('PascalCase');
126
+ expect(camelize("PascalCase")).toEqual("PascalCase");
128
127
  // defaults
129
- expect(camelize()).toEqual('');
128
+ expect(camelize()).toEqual("");
130
129
  });
131
130
 
132
- it('passes words that are single word lowercase', () => {
133
- expect(camelize('lowercase')).toEqual('lowercase');
131
+ it("passes words that are single word lowercase", () => {
132
+ expect(camelize("lowercase")).toEqual("lowercase");
134
133
  });
135
134
 
136
- it('lowercases words that are all uppercase', () => {
137
- expect(camelize('UPPERCASE')).toEqual('uppercase');
135
+ it("lowercases words that are all uppercase", () => {
136
+ expect(camelize("UPPERCASE")).toEqual("uppercase");
138
137
  });
139
138
 
140
- it('turns snake_case words into camelcase', () => {
141
- expect(camelize('snake_case_words')).toEqual('snakeCaseWords');
139
+ it("turns snake_case words into camelcase", () => {
140
+ expect(camelize("snake_case_words")).toEqual("snakeCaseWords");
142
141
  });
143
142
 
144
- it('turns spine-case words into camelcase', () => {
145
- expect(camelize('spine-case-words')).toEqual('spineCaseWords');
143
+ it("turns spine-case words into camelcase", () => {
144
+ expect(camelize("spine-case-words")).toEqual("spineCaseWords");
146
145
  });
147
146
 
148
- it('turns space-separated words into camelcase', () => {
149
- expect(camelize('space separated words')).toEqual('spaceSeparatedWords');
147
+ it("turns space-separated words into camelcase", () => {
148
+ expect(camelize("space separated words")).toEqual("spaceSeparatedWords");
150
149
  });
151
150
  });
152
151
 
153
- describe('once', () => {
154
- it('invokes a function maximum once', () => {
155
- var testFn = jest.fn(),
156
- testFnOnce = once(testFn);
152
+ describe("once", () => {
153
+ it("invokes a function maximum once", () => {
154
+ var testFn = vi.fn(),
155
+ testFnOnce = once(testFn);
157
156
 
158
157
  testFnOnce();
159
158
  testFnOnce();
@@ -166,114 +165,129 @@ describe('Utils', () => {
166
165
  });
167
166
  });
168
167
 
169
- describe('pick', () => {
170
- it('picks an objects properties and returns a new object', () => {
171
- expect(pick({foo: 'foo', bar: 'bar', baz: 'baz'}, 'foo', 'quux')).toEqual({foo: 'foo'});
168
+ describe("pick", () => {
169
+ it("picks an objects properties and returns a new object", () => {
170
+ expect(pick({ foo: "foo", bar: "bar", baz: "baz" }, "foo", "quux")).toEqual({ foo: "foo" });
172
171
  });
173
172
 
174
- it('works with defaults', () => {
173
+ it("works with defaults", () => {
175
174
  expect(pick()).toEqual({});
175
+ expect(pick({ foo: "foo" }, "bar")).toEqual({});
176
+ expect("bar" in pick({ foo: "foo" }, "bar")).toBe(false);
176
177
  });
177
178
  });
178
179
 
179
- describe('omit', () => {
180
- it('omits an objects properties and returns a new object', () => {
181
- expect(omit({foo: 'foo', bar: 'bar', baz: 'baz'}, 'foo', 'quux'))
182
- .toEqual({bar: 'bar', baz: 'baz'});
180
+ describe("omit", () => {
181
+ it("omits an objects properties and returns a new object", () => {
182
+ expect(omit({ foo: "foo", bar: "bar", baz: "baz" }, "foo", "quux")).toEqual({
183
+ bar: "bar",
184
+ baz: "baz",
185
+ });
183
186
  });
184
187
 
185
- it('works with defaults', () => {
188
+ it("works with defaults", () => {
186
189
  expect(omit()).toEqual({});
187
190
  });
188
191
  });
189
192
 
190
- describe('result', () => {
191
- it('returns the correct value if a function', () => {
192
- expect(result({foo: () => 'bar'}, 'foo')).toEqual('bar');
193
- expect(result({foo: (x, y) => x + y + 5}, 'foo', 10, 5)).toEqual(20);
193
+ describe("result", () => {
194
+ it("returns the correct value if a function", () => {
195
+ expect(result({ foo: () => "bar" }, "foo")).toEqual("bar");
196
+ expect(result({ foo: (x, y) => x + y + 5 }, "foo", 10, 5)).toEqual(20);
194
197
  });
195
198
 
196
- it('returns the correct value if not a function', () => {
197
- expect(result({foo: 'bar'}, 'foo')).toEqual('bar');
199
+ it("returns the correct value if not a function", () => {
200
+ expect(result({ foo: "bar" }, "foo")).toEqual("bar");
198
201
  // safe
199
202
  expect(result()).not.toBeDefined();
200
203
  });
201
204
  });
202
205
 
203
- describe('uniqueId', () => {
204
- it('returns a unique id with every call, optionally prefixed', () => {
205
- expect(uniqueId()).toEqual('1');
206
- expect(uniqueId('noah')).toEqual('noah2');
207
- expect(uniqueId()).toEqual('3');
206
+ describe("uniqueId", () => {
207
+ it("returns a unique id with every call, optionally prefixed", () => {
208
+ expect(uniqueId()).toEqual("1");
209
+ expect(uniqueId("noah")).toEqual("noah2");
210
+ expect(uniqueId()).toEqual("3");
208
211
  });
209
212
  });
210
213
 
211
- describe('urlError', () => {
212
- it('throw an error with a message about a missing url', () => {
214
+ describe("urlError", () => {
215
+ it("throw an error with a message about a missing url", () => {
213
216
  expect(urlError).toThrowError('A "url" property or function must be specified');
214
217
  });
215
218
  });
216
219
 
217
- describe('isDeepEqual', () => {
218
- describe('returns true', () => {
219
- it('if the same referential object', () => {
220
+ describe("isDeepEqual", () => {
221
+ describe("returns true", () => {
222
+ it("if the same referential object", () => {
220
223
  var obj = {};
221
224
 
222
225
  expect(isDeepEqual(obj, obj)).toBe(true);
223
226
  });
224
227
 
225
- it('if the objects have equal values, deeply', () => {
226
- expect(isDeepEqual({one: 'one', two: 2, three: null}, {one: 'one', two: 2, three: null}))
227
- .toBe(true);
228
+ it("if the objects have equal values, deeply", () => {
229
+ expect(
230
+ isDeepEqual({ one: "one", two: 2, three: null }, { one: "one", two: 2, three: null })
231
+ ).toBe(true);
228
232
  // nested
229
- expect(isDeepEqual({
230
- one: 'one',
231
- two: {three: 'three'}
232
- }, {
233
- one: 'one',
234
- two: {three: 'three'}
235
- })).toBe(true);
233
+ expect(
234
+ isDeepEqual(
235
+ {
236
+ one: "one",
237
+ two: { three: "three" },
238
+ },
239
+ {
240
+ one: "one",
241
+ two: { three: "three" },
242
+ }
243
+ )
244
+ ).toBe(true);
236
245
  });
237
246
  });
238
247
 
239
- describe('returns false', () => {
240
- it('if not objects', () => {
248
+ describe("returns false", () => {
249
+ it("if not objects", () => {
241
250
  expect(isDeepEqual(null, false)).toBe(false);
242
251
  });
243
252
 
244
- it('if one object has more properties', () => {
245
- expect(isDeepEqual({one: 'one', two: 'two'}, {one: 'one'})).toBe(false);
253
+ it("if one object has more properties", () => {
254
+ expect(isDeepEqual({ one: "one", two: "two" }, { one: "one" })).toBe(false);
246
255
  });
247
256
 
248
- it('if the objects do not have equal values', () => {
249
- expect(isDeepEqual({one: 'one'}, {one: 'two'})).toBe(false);
250
- expect(isDeepEqual({one: 'one'}, {two: 'three'})).toBe(false);
257
+ it("if the objects do not have equal values", () => {
258
+ expect(isDeepEqual({ one: "one" }, { one: "two" })).toBe(false);
259
+ expect(isDeepEqual({ one: "one" }, { two: "three" })).toBe(false);
251
260
  // nested
252
- expect(isDeepEqual({one: {two: 'three'}}, {one: {two: 'four'}})).toBe(false);
261
+ expect(isDeepEqual({ one: { two: "three" } }, { one: { two: "four" } })).toBe(false);
253
262
  });
254
263
  });
255
264
  });
256
265
 
257
- describe('sortBy', () => {
258
- it('sorts a list by a comparator function', () => {
259
- expect(sortBy([
260
- {name: 'zorah'},
261
- {name: 'alex'},
262
- {name: undefined},
263
- {name: 'noah'},
264
- {name: undefined},
265
- {name: 'alex'},
266
- {name: 'zorah'},
267
- {name: 'alex'}
268
- ], ({name}) => name)).toEqual([
269
- {name: 'alex'},
270
- {name: 'alex'},
271
- {name: 'alex'},
272
- {name: 'noah'},
273
- {name: 'zorah'},
274
- {name: 'zorah'},
275
- {name: undefined},
276
- {name: undefined}
266
+ describe("sortBy", () => {
267
+ it("sorts a list by a comparator function", () => {
268
+ expect(
269
+ sortBy(
270
+ [
271
+ { name: "zorah" },
272
+ { name: "alex" },
273
+ { name: undefined },
274
+ { name: "noah" },
275
+ { name: undefined },
276
+ { name: "alex" },
277
+ { name: "zorah" },
278
+ { name: "alex" },
279
+ ],
280
+ ({ name }) => name
281
+ )
282
+ ).toEqual([
283
+ { name: "alex" },
284
+ { name: "alex" },
285
+ { name: "alex" },
286
+ { name: "noah" },
287
+ { name: "zorah" },
288
+ { name: "zorah" },
289
+ { name: undefined },
290
+ { name: undefined },
277
291
  ]);
278
292
 
279
293
  expect(sortBy()).toEqual([]);