/
dedaMazai
/
TestServer
Обзор
Документация
Войти
/
dedaMazai
/
TestServer
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/features/editableProfileCard/model/services/fetchProfileData/fetchProfileData.test.ts
35 строк
1 KB
Andrey Chipizubov
fix
23 апр 2023, 17:32
23 апр 2023, 17:32
cc424e9
Код
Авторство
О чём код?
import { TestAsyncThunk } from '@/shared/lib/tests/TestAsyncThunk/TestAsyncThunk'; import { Country } from '@/entities/Country'; import { Currency } from '@/entities/Currency'; import { fetchProfileData } from './fetchProfileData'; const data = { username: 'admin', age: 22, country: Country.Ukraine, lastname: 'ulbi tv', first: 'asd', city: 'asf', currency: Currency.USD, }; describe('fetchProfileData.test', () => { test('success', async () => { const thunk = new TestAsyncThunk(fetchProfileData); thunk.api.get.mockReturnValue(Promise.resolve({ data })); const result = await thunk.callThunk('1'); expect(thunk.api.get).toHaveBeenCalled(); expect(result.meta.requestStatus).toBe('fulfilled'); expect(result.payload).toEqual(data); }); test('error login', async () => { const thunk = new TestAsyncThunk(fetchProfileData); thunk.api.get.mockReturnValue(Promise.resolve({ status: 403 })); const result = await thunk.callThunk('1'); expect(result.meta.requestStatus).toBe('rejected'); }); });