Skip to content

Commit

Permalink
Extract test constant
Browse files Browse the repository at this point in the history
  • Loading branch information
pbrisbin committed Feb 14, 2024
1 parent 552b640 commit be58608
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/envsubst.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { envsubst } from "./envsubst";

const HOME = process.env.HOME;

describe("envsubst", () => {
test("known variables are replaced", () => {
expect(envsubst("Home is $HOME.")).toEqual(`Home is ${process.env.HOME}.`);
expect(envsubst("Home is $HOME.")).toEqual(`Home is ${HOME}.`);
});

test("known variables with braces are replaced", () => {
expect(envsubst("Home is ${HOME}.")).toEqual(
`Home is ${process.env.HOME}.`,
);
expect(envsubst("Home is ${HOME}.")).toEqual(`Home is ${HOME}.`);
});

test("unknown variables are replaced by whitespace", () => {
Expand All @@ -29,8 +29,6 @@ describe("envsubst", () => {
});

test("mismatched right brace is replaced before the brace", () => {
expect(envsubst("Home is $HOME}.")).toEqual(
`Home is ${process.env.HOME}}.`,
);
expect(envsubst("Home is $HOME}.")).toEqual(`Home is ${HOME}}.`);
});
});

0 comments on commit be58608

Please sign in to comment.