From be58608ea94631d3480b113f24b7a934d9cc243f Mon Sep 17 00:00:00 2001 From: patrick brisbin Date: Wed, 14 Feb 2024 13:13:57 -0500 Subject: [PATCH] Extract test constant --- src/envsubst.test.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/envsubst.test.ts b/src/envsubst.test.ts index dcc965f..3f842d4 100644 --- a/src/envsubst.test.ts +++ b/src/envsubst.test.ts @@ -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", () => { @@ -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}}.`); }); });