/
Muip
/
ProBody
Обзор
Документация
Войти
/
Muip
/
ProBody
Код
Запросы
0
Задачи
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
api/ApiClient.test.ts
44 строки
1 KB
chmerev
new
14 авг 2024, 12:02
14 авг 2024, 12:02
595f266
Код
Авторство
О чём код?
import ApiClient from './ApiClient'; const schoolUrl = 'https://test-school.accelonline.io/api/v1'; const email = 'dmusato@gmail.com'; const password = '123456'; const storage = {} as any; const clientApi = new ApiClient({ baseUrl: schoolUrl, debug: true, auth: { access: { durationDays: 1, name: 'a', }, refresh: { name: 'r', durationDays: 1, } }, saveToken: async (key: string, value: string) => { storage[key] = value; }, getToken: async (key: string) => storage[key], deleteToken: async (key: string) => { delete storage[key] }, }); describe('Auth', () => { test('Login', async () => { const res = await clientApi.user.login({ email: email, password: password }) storage['a'] = res.body?.accessToken; storage['r'] = res.body?.refreshToken; expect(res.body?.accessToken).not.toBeNull(); expect(res.body?.refreshToken).not.toBeNull(); }); test('Refresh', async () => { delete storage['a']; const refreshRes = await clientApi.user.me(); expect(refreshRes.body).not.toBeNull(); }); });