Skip to content
Snippets Groups Projects
gameslist.test.ts 1.06 KiB
Newer Older
Yusuf Akgül's avatar
Yusuf Akgül committed
describe('games list api', () => {

    const mockGamesData = [
        {
            id: 1,
            name: 'Game 1',
            cover: {
                image_id: 'cover_image_id_1',
                url: 'cover_image_url_1'
            },
        },
        {
            id: 2,
            name: 'Game 2',
            cover: {
                image_id: 'cover_image_id_2',
                url: 'cover_image_url_2'
            },
        },
    ];

    const mockAuthData = [
        {
            access_token: "1",
            expires_in: 420,
            token_type: 'bearer',
        }
    ]

    beforeAll(async () => {
        global.fetch = jest.fn()
            .mockResolvedValueOnce(() => Promise.resolve({
                ok: true,
                json: () => Promise.resolve(mockAuthData),
            }))
            .mockResolvedValueOnce(() => Promise.resolve({
                ok: true,
                json: () => Promise.resolve(mockGamesData),
            }))
    });

    test('get gameslist', async () => {
        expect("test").toEqual("test");
    });
});