unit tests
This commit is contained in:
parent
7cad598269
commit
efacbe861a
|
@ -0,0 +1,38 @@
|
|||
const setup = require("./utilities")
|
||||
|
||||
// mock the email system
|
||||
const sendMailMock = jest.fn()
|
||||
jest.mock("nodemailer")
|
||||
const nodemailer = require("nodemailer")
|
||||
nodemailer.createTransport.mockReturnValue({
|
||||
verify: jest.fn()
|
||||
})
|
||||
|
||||
describe("/api/admin/configs/checklist", () => {
|
||||
let request = setup.getRequest()
|
||||
let config = setup.getConfig()
|
||||
|
||||
beforeAll(async () => {
|
||||
await config.init()
|
||||
})
|
||||
|
||||
afterAll(setup.afterAll)
|
||||
|
||||
it("should return the correct checklist status based on the state of the budibase installation", async () => {
|
||||
// initially configure settings
|
||||
await config.saveAdminUser()
|
||||
await config.saveSmtpConfig()
|
||||
|
||||
const res = await request
|
||||
.get(`/api/admin/configs/checklist`)
|
||||
.set(config.defaultHeaders())
|
||||
.expect("Content-Type", /json/)
|
||||
.expect(200)
|
||||
|
||||
const checklist = res.body
|
||||
|
||||
expect(checklist.apps).toBe(0)
|
||||
expect(checklist.smtp).toBe(true)
|
||||
expect(checklist.adminUser).toBe(true)
|
||||
})
|
||||
})
|
|
@ -105,6 +105,22 @@ class TestConfiguration {
|
|||
)
|
||||
}
|
||||
|
||||
async saveOAuthConfig() {
|
||||
await this.deleteConfig(Configs.GOOGLE)
|
||||
await this._req(
|
||||
{
|
||||
type: Configs.GOOGLE,
|
||||
config: {
|
||||
callbackURL: "http://somecallbackurl",
|
||||
clientID: "clientId",
|
||||
clientSecret: "clientSecret",
|
||||
},
|
||||
},
|
||||
null,
|
||||
controllers.config.save
|
||||
)
|
||||
}
|
||||
|
||||
async saveSmtpConfig() {
|
||||
await this.deleteConfig(Configs.SMTP)
|
||||
await this._req(
|
||||
|
@ -141,6 +157,17 @@ class TestConfiguration {
|
|||
controllers.config.save
|
||||
)
|
||||
}
|
||||
|
||||
async saveAdminUser() {
|
||||
await this._req(
|
||||
{
|
||||
email: "testuser@test.com",
|
||||
password: "test@test.com"
|
||||
},
|
||||
null,
|
||||
controllers.users.adminUser
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = TestConfiguration
|
||||
|
|
Loading…
Reference in New Issue