housekeeping: reorganize and rewire Mocha tests (#5600)
* move Mocha-run tests to `test/mocha` * fix relative paths * fix JSX test paths * update stagnated JSX tests * `test/setup.js` -> `test/mocha/setup.js` * use regex+globstar for test matching * remove `console.log`
This commit is contained in:
58
test/mocha/docker/oauth.js
Normal file
58
test/mocha/docker/oauth.js
Normal file
@@ -0,0 +1,58 @@
|
||||
const expect = require("expect")
|
||||
const oauthBlockBuilder = require("../../../docker/configurator/oauth")
|
||||
const dedent = require("dedent")
|
||||
|
||||
describe("docker: env translator - oauth block", function() {
|
||||
it("should omit the block if there are no valid keys", function () {
|
||||
const input = {}
|
||||
|
||||
expect(oauthBlockBuilder(input)).toEqual(``)
|
||||
})
|
||||
it("should omit the block if there are no valid keys", function () {
|
||||
const input = {
|
||||
NOT_A_VALID_KEY: "asdf1234"
|
||||
}
|
||||
|
||||
expect(oauthBlockBuilder(input)).toEqual(``)
|
||||
})
|
||||
it("should generate a block from empty values", function() {
|
||||
const input = {
|
||||
OAUTH_CLIENT_ID: ``,
|
||||
OAUTH_CLIENT_SECRET: ``,
|
||||
OAUTH_REALM: ``,
|
||||
OAUTH_APP_NAME: ``,
|
||||
OAUTH_SCOPE_SEPARATOR: "",
|
||||
OAUTH_ADDITIONAL_PARAMS: ``,
|
||||
}
|
||||
|
||||
expect(oauthBlockBuilder(input)).toEqual(dedent(`
|
||||
ui.initOAuth({
|
||||
clientId: "",
|
||||
clientSecret: "",
|
||||
realm: "",
|
||||
appName: "",
|
||||
scopeSeparator: "",
|
||||
additionalQueryStringParams: undefined,
|
||||
})`))
|
||||
})
|
||||
it("should generate a full block", function() {
|
||||
const input = {
|
||||
OAUTH_CLIENT_ID: `myId`,
|
||||
OAUTH_CLIENT_SECRET: `mySecret`,
|
||||
OAUTH_REALM: `myRealm`,
|
||||
OAUTH_APP_NAME: `myAppName`,
|
||||
OAUTH_SCOPE_SEPARATOR: "%21",
|
||||
OAUTH_ADDITIONAL_PARAMS: `{ "a": 1234, "b": "stuff" }`,
|
||||
}
|
||||
|
||||
expect(oauthBlockBuilder(input)).toEqual(dedent(`
|
||||
ui.initOAuth({
|
||||
clientId: "myId",
|
||||
clientSecret: "mySecret",
|
||||
realm: "myRealm",
|
||||
appName: "myAppName",
|
||||
scopeSeparator: "%21",
|
||||
additionalQueryStringParams: { "a": 1234, "b": "stuff" },
|
||||
})`))
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user