Adding unit test.
This commit is contained in:
parent
020129ed02
commit
c869cf23f9
|
@ -1,4 +1,4 @@
|
||||||
import { InviteUsersResponse } from "@budibase/types"
|
import { InviteUsersResponse, User } from "@budibase/types"
|
||||||
|
|
||||||
jest.mock("nodemailer")
|
jest.mock("nodemailer")
|
||||||
import {
|
import {
|
||||||
|
@ -298,6 +298,23 @@ describe("/api/global/users", () => {
|
||||||
expect(events.user.passwordForceReset).not.toBeCalled()
|
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 () => {
|
it("should be able to force reset password", async () => {
|
||||||
const user = await config.createUser()
|
const user = await config.createUser()
|
||||||
jest.clearAllMocks()
|
jest.clearAllMocks()
|
||||||
|
|
Loading…
Reference in New Issue