feat: admin frontend - React + Vite, auth pages, user management, roles, permissions, webhooks, devices, logs
This commit is contained in:
35
frontend/admin/src/services/users.test.ts
Normal file
35
frontend/admin/src/services/users.test.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
const getMock = vi.fn()
|
||||
const postMock = vi.fn()
|
||||
const putMock = vi.fn()
|
||||
const delMock = vi.fn()
|
||||
|
||||
vi.mock('@/lib/http/client', () => ({
|
||||
get: getMock,
|
||||
post: postMock,
|
||||
put: putMock,
|
||||
del: delMock,
|
||||
}))
|
||||
|
||||
describe('users service', () => {
|
||||
beforeEach(() => {
|
||||
getMock.mockReset()
|
||||
postMock.mockReset()
|
||||
putMock.mockReset()
|
||||
delMock.mockReset()
|
||||
})
|
||||
|
||||
it('creates a user through the protected users endpoint', async () => {
|
||||
const payload = {
|
||||
username: 'new-user',
|
||||
password: 'Pass123!@#',
|
||||
role_ids: [2],
|
||||
}
|
||||
|
||||
const { createUser } = await import('./users')
|
||||
await createUser(payload)
|
||||
|
||||
expect(postMock).toHaveBeenCalledWith('/users', payload)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user