From 3631ca32bdeb83349da8aef169474bdeae667292 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Sun, 8 Sep 2024 13:07:46 +0000 Subject: [PATCH] Fix tests --- __tests__/api.test.ts | 15 +++++++++------ __tests__/sum.test.ts | 6 ++++-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/__tests__/api.test.ts b/__tests__/api.test.ts index 0f04b01..cee8ee8 100644 --- a/__tests__/api.test.ts +++ b/__tests__/api.test.ts @@ -7,11 +7,14 @@ jest.mock('axios'); const mockedAxios = axios as jest.Mocked; -it('fetches successfully data from an API', async () => { - const data = { data: { userId: 1, id: 1, title: 'mock title' } }; - mockedAxios.get.mockResolvedValue(data); +describe('api', () => { + it('fetches successfully data from an API', async () => { + const data = { data: { userId: 1, id: 1, title: 'mock title' } }; + mockedAxios.get.mockResolvedValue(data); - const result = await fetchData('https://jsonplaceholder.typicode.com/todos/1'); - expect(result).toEqual(data.data); - expect(mockedAxios.get).toHaveBeenCalledTimes(1); + const result = await fetchData('https://jsonplaceholder.typicode.com/todos/1'); + expect(result).toEqual(data.data); + expect(mockedAxios.get).toHaveBeenCalledTimes(1); + }); }); + diff --git a/__tests__/sum.test.ts b/__tests__/sum.test.ts index 8be66bf..2a295d5 100644 --- a/__tests__/sum.test.ts +++ b/__tests__/sum.test.ts @@ -1,6 +1,8 @@ import { test, expect } from '@jest/globals'; import { sum } from '../src/sum'; -test('adds 1 + 2 to equal 3', () => { - expect(sum(1, 2)).toBe(3); +describe('sum', () => { + test('adds 1 + 2 to equal 3', () => { + expect(sum(1, 2)).toBe(3); + }); });