Skip to content

Commit e07eac2

Browse files
committed
npm run fmt
1 parent a89939a commit e07eac2

2 files changed

Lines changed: 16 additions & 6 deletions

File tree

mock-api/msw/util.spec.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ describe('paginated', () => {
8383

8484
it('pages through id_ascending with no overlap and no gap', () => {
8585
// Items a..j; token is the first item of the next page (inclusive marker)
86-
const items = Array.from({ length: 10 }, (_, i) => ({ id: String.fromCharCode(97 + i) }))
86+
const items = Array.from({ length: 10 }, (_, i) => ({
87+
id: String.fromCharCode(97 + i),
88+
}))
8789
const p1 = paginated({ limit: 3 }, items)
8890
expect(p1.items.map((i) => i.id)).toEqual(['a', 'b', 'c'])
8991
expect(p1.next_page).toBe('c')
@@ -124,7 +126,10 @@ describe('paginated', () => {
124126
// next_page token format is "name|id" — last item on page, not first of next
125127
expect(p1.next_page).toBe('yak|c')
126128

127-
const p2 = paginated({ sortBy: 'name_descending', limit: 2, pageToken: p1.next_page }, items)
129+
const p2 = paginated(
130+
{ sortBy: 'name_descending', limit: 2, pageToken: p1.next_page },
131+
items
132+
)
128133
expect(p2.items.map((i) => i.name)).toEqual(['xerox', 'walrus'])
129134
expect(p2.next_page).toBeNull()
130135
})
@@ -154,7 +159,10 @@ describe('paginated', () => {
154159
// next_page token format is "timestamp|id" — last item on page, not first of next
155160
expect(p1.next_page).toBe(`${t1}|c`)
156161

157-
const p2 = paginated({ sortBy: 'time_and_id_ascending', limit: 2, pageToken: p1.next_page }, items)
162+
const p2 = paginated(
163+
{ sortBy: 'time_and_id_ascending', limit: 2, pageToken: p1.next_page },
164+
items
165+
)
158166
expect(p2.items.map((i) => i.id)).toEqual(['b'])
159167
expect(p2.next_page).toBeNull()
160168
})
@@ -172,7 +180,10 @@ describe('paginated', () => {
172180
expect(p1.items.map((i) => i.id)).toEqual(['b', 'a'])
173181
expect(p1.next_page).toBe(`${t1}|a`)
174182

175-
const p2 = paginated({ sortBy: 'time_and_id_descending', limit: 2, pageToken: p1.next_page }, items)
183+
const p2 = paginated(
184+
{ sortBy: 'time_and_id_descending', limit: 2, pageToken: p1.next_page },
185+
items
186+
)
176187
expect(p2.items.map((i) => i.id)).toEqual(['c'])
177188
expect(p2.next_page).toBeNull()
178189
})

mock-api/msw/util.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,7 @@ export const paginated = <P extends PaginateOptions, I extends { id: string }>(
192192
// - id_ascending for endpoints that only support id sorting
193193
// Note: time_and_id_ascending is only used when explicitly specified in sortBy
194194
const sortBy =
195-
params.sortBy ||
196-
(items.some((i) => 'name' in i) ? 'name_ascending' : 'id_ascending')
195+
params.sortBy || (items.some((i) => 'name' in i) ? 'name_ascending' : 'id_ascending')
197196

198197
const sortedItems = sortItems(items, sortBy)
199198

0 commit comments

Comments
 (0)