/
kreyndelHam
/
Konstructorium
Обзор
Документация
Войти
/
kreyndelHam
/
Konstructorium
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
1
CI/CD
Аналитика
Безопасность
dev
frontend/src/utils/adminPaginatedList.test.js
37 строк
1 KB
MihahamYT
Docs + notifications + SMTP emails
25 май 2026, 14:46
25 май 2026, 14:46
c95f449
Код
Авторство
О чём код?
import { describe, expect, it, vi } from 'vitest' import { adminListPathFromNextUrl, extractAdminListPage, fetchAllAdminListPages, } from './adminPaginatedList.js' describe('adminPaginatedList', () => { it('extractAdminListPage handles array and DRF page', () => { expect(extractAdminListPage([{ id: 1 }])).toEqual([{ id: 1 }]) expect(extractAdminListPage({ results: [{ id: 2 }], count: 1 })).toEqual([{ id: 2 }]) expect(extractAdminListPage({})).toEqual([]) }) it('adminListPathFromNextUrl extracts path under /api/admin', () => { const path = adminListPathFromNextUrl('http://127.0.0.1:8006/api/admin/notifications/?page=2') expect(path).toBe('/notifications/?page=2') }) it('fetchAllAdminListPages follows next links', async () => { const fetchFirstPage = vi.fn().mockResolvedValue({ data: { results: [{ id: 1 }], next: 'http://localhost/api/admin/notifications/?page=2', }, }) const fetchByPath = vi.fn().mockResolvedValue({ data: { results: [{ id: 2 }], next: null }, }) const items = await fetchAllAdminListPages(fetchFirstPage, {}, fetchByPath) expect(items).toEqual([{ id: 1 }, { id: 2 }]) expect(fetchByPath).toHaveBeenCalledWith('/notifications/?page=2') }) })