Adding unit test.

This commit is contained in:
mike12345567 2022-12-07 18:37:23 +00:00
parent 020129ed02
commit c869cf23f9
1 changed files with 18 additions and 1 deletions

View File

@ -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()