Skip to content

Commit d927b46

Browse files
committed
add unit tests
1 parent b0bfe0a commit d927b46

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

tests/unit/functions/server_functions_spec.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
1-
const { cors, getUserAgent } = require("#server_functions");
1+
const { cors, getUserAgent, replaceSecretPlaceholder } = require("#server_functions");
22

33
describe("server_functions tests", () => {
4+
describe("The replaceSecretPlaceholder method", () => {
5+
it("Calls string without secret placeholder", () => {
6+
const teststring = "test string without secret placeholder";
7+
const result = replaceSecretPlaceholder(teststring);
8+
expect(result).toBe(teststring);
9+
});
10+
11+
it("Calls string with 2 secret placeholders", () => {
12+
const teststring = "test string with secret1=**SECRET_ONE** and secret2=**SECRET_TWO**";
13+
process.env.SECRET_ONE = "secret1";
14+
process.env.SECRET_TWO = "secret2";
15+
const resultstring = `test string with secret1=${process.env.SECRET_ONE} and secret2=${process.env.SECRET_TWO}`;
16+
const result = replaceSecretPlaceholder(teststring);
17+
expect(result).toBe(resultstring);
18+
});
19+
});
20+
421
describe("The cors method", () => {
522
let fetchResponse;
623
let fetchResponseHeadersGet;

0 commit comments

Comments
 (0)