refactor: make password param to defaultConfigFile
This commit is contained in:
@ -14,7 +14,7 @@ import {
|
||||
splitOnFirstEquals,
|
||||
} from "../../../src/node/cli"
|
||||
import { tmpdir } from "../../../src/node/constants"
|
||||
import { paths } from "../../../src/node/util"
|
||||
import { generatePassword, paths } from "../../../src/node/util"
|
||||
import { useEnv } from "../../utils/helpers"
|
||||
|
||||
type Mutable<T> = {
|
||||
@ -645,16 +645,13 @@ describe("bindAddrFromArgs", () => {
|
||||
})
|
||||
|
||||
describe("defaultConfigFile", () => {
|
||||
it("should return the dfeault config file as a string", async () => {
|
||||
const actualDefaultConfigFile = await defaultConfigFile()
|
||||
// Since the password is autogenerated within the function
|
||||
// we can't assert it with .toMatch
|
||||
// but we can check that the config at least includes
|
||||
// these strings.
|
||||
const expectedStrings = [`bind-addr: 127.0.0.1:8080`, `auth: password`, `password`, `cert: false`]
|
||||
it("should return the default config file as a string", async () => {
|
||||
const password = await generatePassword()
|
||||
const actual = defaultConfigFile(password)
|
||||
|
||||
expectedStrings.forEach((str) => {
|
||||
expect(actualDefaultConfigFile).toContain(str)
|
||||
})
|
||||
expect(actual).toMatch(`bind-addr: 127.0.0.1:8080
|
||||
auth: password
|
||||
password: ${password}
|
||||
cert: false`)
|
||||
})
|
||||
})
|
||||
|
Reference in New Issue
Block a user