Adding unit test.
This commit is contained in:
parent
16ecdddb8a
commit
0809c025d1
|
@ -1,4 +1,4 @@
|
|||
import { InviteUsersResponse } from "@budibase/types"
|
||||
import { InviteUsersResponse, User } from "@budibase/types"
|
||||
|
||||
jest.mock("nodemailer")
|
||||
import {
|
||||
|
@ -298,6 +298,23 @@ describe("/api/global/users", () => {
|
|||
expect(events.user.passwordForceReset).not.toBeCalled()
|
||||
})
|
||||
|
||||
it("should not allow a user to update their own admin/builder status", async () => {
|
||||
const user = (await config.api.users.getUser(config.defaultUser?._id!))
|
||||
.body as User
|
||||
await config.api.users.saveUser({
|
||||
...user,
|
||||
admin: {
|
||||
global: false,
|
||||
},
|
||||
builder: {
|
||||
global: false,
|
||||
},
|
||||
})
|
||||
const userOut = (await config.api.users.getUser(user._id!)).body
|
||||
expect(userOut.admin.global).toBe(true)
|
||||
expect(userOut.builder.global).toBe(true)
|
||||
})
|
||||
|
||||
it("should be able to force reset password", async () => {
|
||||
const user = await config.createUser()
|
||||
jest.clearAllMocks()
|
||||
|
|
Loading…
Reference in New Issue