40 lines
1.3 KiB
TypeScript
40 lines
1.3 KiB
TypeScript
|
import { AboutUsService } from "../client/services"
|
||
|
import { aboutUsResponse, aboutUsData } from "../utils/user"
|
||
|
|
||
|
describe('AboutUsService', () => {
|
||
|
it('should fetch AboutUs data', async () => {
|
||
|
jest.spyOn(global, 'fetch').mockResolvedValue({
|
||
|
json: jest.fn().mockResolvedValue(aboutUsResponse),
|
||
|
} as Response)
|
||
|
|
||
|
const response = await AboutUsService.getAbouts()
|
||
|
expect(response).toEqual(aboutUsData)
|
||
|
})
|
||
|
|
||
|
it('should create a new AboutUs', async () => {
|
||
|
jest.spyOn(global, 'fetch').mockResolvedValue({
|
||
|
json: jest.fn().mockResolvedValue({ id: '1' }),
|
||
|
} as Response)
|
||
|
|
||
|
const response = await AboutUsService.createAboutUs(aboutUsData[0])
|
||
|
expect(response).toEqual({ id: '1' })
|
||
|
})
|
||
|
|
||
|
it('should update an AboutUs', async () => {
|
||
|
jest.spyOn(global, 'fetch').mockResolvedValue({
|
||
|
json: jest.fn().mockResolvedValue({ id: '1' }),
|
||
|
} as Response)
|
||
|
|
||
|
const response = await AboutUsService.updateAboutUs(aboutUsData[0].id, aboutUsData[0])
|
||
|
expect(response).toEqual({ id: '1' })
|
||
|
})
|
||
|
|
||
|
it('should delete an AboutUs', async () => {
|
||
|
jest.spyOn(global, 'fetch').mockResolvedValue({
|
||
|
json: jest.fn().mockResolvedValue({ id: '1' }),
|
||
|
} as Response)
|
||
|
|
||
|
const response = await AboutUsService.deleteAboutUs({ id: '1' } as any)
|
||
|
expect(response).toEqual({ id: '1' })
|
||
|
})
|
||
|
})
|