feat: migrate unit tests to Jest (#6353)
* config(jest): updated setup * config(jest): update testMatch to include jsx files * config(jest): add transformIgnorePatterns * config(jest): update ignore files that do not work in jest yet * config: add test:unit-jest to test script * fix(jest): lint with eslint-plugin-jest * refactor(jest): move unit test directory * refactor(mocha): restore mocha tests that fail in jest * docs(jest): update helpful scripts with test:unit-jest
This commit is contained in:
62
test/unit/docker/oauth.js
Normal file
62
test/unit/docker/oauth.js
Normal file
@@ -0,0 +1,62 @@
|
||||
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: ``,
|
||||
OAUTH_USE_PKCE: false
|
||||
}
|
||||
|
||||
expect(oauthBlockBuilder(input)).toEqual(dedent(`
|
||||
ui.initOAuth({
|
||||
clientId: "",
|
||||
clientSecret: "",
|
||||
realm: "",
|
||||
appName: "",
|
||||
scopeSeparator: "",
|
||||
additionalQueryStringParams: undefined,
|
||||
usePkceWithAuthorizationCodeGrant: false,
|
||||
})`))
|
||||
})
|
||||
|
||||
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" }`,
|
||||
OAUTH_USE_PKCE: true
|
||||
}
|
||||
|
||||
expect(oauthBlockBuilder(input)).toEqual(dedent(`
|
||||
ui.initOAuth({
|
||||
clientId: "myId",
|
||||
clientSecret: "mySecret",
|
||||
realm: "myRealm",
|
||||
appName: "myAppName",
|
||||
scopeSeparator: "%21",
|
||||
additionalQueryStringParams: { "a": 1234, "b": "stuff" },
|
||||
usePkceWithAuthorizationCodeGrant: true,
|
||||
})`))
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user