|
8 | 8 | isRepoInIntegration, |
9 | 9 | normalizeRepoKey, |
10 | 10 | type RepositoryCacheAction, |
| 11 | + type RepositoryPickerList, |
| 12 | + type RepositoryPickerListInputs, |
11 | 13 | type RepositoryQueryResult, |
12 | 14 | resolveEffectiveUserRepositoryMap, |
13 | 15 | resolveRepositoryPickerList, |
@@ -316,70 +318,69 @@ describe("resolveRepositoryPickerList", () => { |
316 | 318 | const allRepositories = ["a/x", "a/y"]; |
317 | 319 | const pickerRepositories = ["a/x"]; |
318 | 320 |
|
319 | | - it("shows the full list while the picker is closed", () => { |
320 | | - const result = resolveRepositoryPickerList({ |
321 | | - pickerOpen: false, |
322 | | - pickerPending: true, |
323 | | - searchActive: false, |
324 | | - pickerRepositories, |
325 | | - allRepositories, |
326 | | - }); |
327 | | - expect(result).toEqual({ |
328 | | - repositories: allRepositories, |
329 | | - pickerLoading: false, |
330 | | - }); |
331 | | - }); |
332 | | - |
333 | | - it("falls back to the full list while the first picker page loads", () => { |
334 | | - const result = resolveRepositoryPickerList({ |
335 | | - pickerOpen: true, |
336 | | - pickerPending: true, |
337 | | - searchActive: false, |
338 | | - pickerRepositories: [], |
339 | | - allRepositories, |
340 | | - }); |
341 | | - expect(result).toEqual({ |
342 | | - repositories: allRepositories, |
343 | | - pickerLoading: false, |
344 | | - }); |
345 | | - }); |
346 | | - |
347 | | - it("shows the loading picker list while a search is pending", () => { |
348 | | - const result = resolveRepositoryPickerList({ |
349 | | - pickerOpen: true, |
350 | | - pickerPending: true, |
351 | | - searchActive: true, |
352 | | - pickerRepositories, |
353 | | - allRepositories, |
354 | | - }); |
355 | | - expect(result).toEqual({ |
356 | | - repositories: pickerRepositories, |
357 | | - pickerLoading: true, |
358 | | - }); |
359 | | - }); |
360 | | - |
361 | | - it("keeps the loading state when there is no full list to fall back to", () => { |
362 | | - const result = resolveRepositoryPickerList({ |
363 | | - pickerOpen: true, |
364 | | - pickerPending: true, |
365 | | - searchActive: false, |
366 | | - pickerRepositories: [], |
367 | | - allRepositories: [], |
368 | | - }); |
369 | | - expect(result).toEqual({ repositories: [], pickerLoading: true }); |
370 | | - }); |
| 321 | + const cases: Array<{ |
| 322 | + name: string; |
| 323 | + inputs: RepositoryPickerListInputs; |
| 324 | + expected: RepositoryPickerList; |
| 325 | + }> = [ |
| 326 | + { |
| 327 | + name: "shows the full list while the picker is closed", |
| 328 | + inputs: { |
| 329 | + pickerOpen: false, |
| 330 | + pickerPending: true, |
| 331 | + searchActive: false, |
| 332 | + pickerRepositories, |
| 333 | + allRepositories, |
| 334 | + }, |
| 335 | + expected: { repositories: allRepositories, pickerLoading: false }, |
| 336 | + }, |
| 337 | + { |
| 338 | + name: "falls back to the full list while the first picker page loads", |
| 339 | + inputs: { |
| 340 | + pickerOpen: true, |
| 341 | + pickerPending: true, |
| 342 | + searchActive: false, |
| 343 | + pickerRepositories: [], |
| 344 | + allRepositories, |
| 345 | + }, |
| 346 | + expected: { repositories: allRepositories, pickerLoading: false }, |
| 347 | + }, |
| 348 | + { |
| 349 | + name: "shows the loading picker list while a search is pending", |
| 350 | + inputs: { |
| 351 | + pickerOpen: true, |
| 352 | + pickerPending: true, |
| 353 | + searchActive: true, |
| 354 | + pickerRepositories, |
| 355 | + allRepositories, |
| 356 | + }, |
| 357 | + expected: { repositories: pickerRepositories, pickerLoading: true }, |
| 358 | + }, |
| 359 | + { |
| 360 | + name: "keeps the loading state when there is no full list to fall back to", |
| 361 | + inputs: { |
| 362 | + pickerOpen: true, |
| 363 | + pickerPending: true, |
| 364 | + searchActive: false, |
| 365 | + pickerRepositories: [], |
| 366 | + allRepositories: [], |
| 367 | + }, |
| 368 | + expected: { repositories: [], pickerLoading: true }, |
| 369 | + }, |
| 370 | + { |
| 371 | + name: "shows the picker list once it settles", |
| 372 | + inputs: { |
| 373 | + pickerOpen: true, |
| 374 | + pickerPending: false, |
| 375 | + searchActive: false, |
| 376 | + pickerRepositories, |
| 377 | + allRepositories, |
| 378 | + }, |
| 379 | + expected: { repositories: pickerRepositories, pickerLoading: false }, |
| 380 | + }, |
| 381 | + ]; |
371 | 382 |
|
372 | | - it("shows the picker list once it settles", () => { |
373 | | - const result = resolveRepositoryPickerList({ |
374 | | - pickerOpen: true, |
375 | | - pickerPending: false, |
376 | | - searchActive: false, |
377 | | - pickerRepositories, |
378 | | - allRepositories, |
379 | | - }); |
380 | | - expect(result).toEqual({ |
381 | | - repositories: pickerRepositories, |
382 | | - pickerLoading: false, |
383 | | - }); |
| 383 | + it.each(cases)("$name", ({ inputs, expected }) => { |
| 384 | + expect(resolveRepositoryPickerList(inputs)).toEqual(expected); |
384 | 385 | }); |
385 | 386 | }); |
0 commit comments