Updated courses model and fixed rich text editor tool bar drop down problem

This commit is contained in:
2024-10-03 10:28:33 +08:00
parent 42fbcc5d89
commit 68378d55ac
20 changed files with 652 additions and 28 deletions

View File

@@ -0,0 +1,40 @@
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' })
})
})