chore: tests for hoppscotch-cli (#2300)

Co-authored-by: Andrew Bastin <andrewbastin.k@gmail.com>
This commit is contained in:
Deepanshu Dhruw
2022-05-11 15:44:19 +05:30
committed by GitHub
parent d04520698d
commit 432337b801
30 changed files with 1919 additions and 155 deletions

View File

@@ -0,0 +1,42 @@
import { Environment } from "@hoppscotch/data";
import { getEffectiveFinalMetaData } from "../../../utils/getters";
const DEFAULT_ENV = <Environment>{
name: "name",
variables: [{ key: "PARAM", value: "parsed_param" }],
};
describe("getEffectiveFinalMetaData", () => {
test("Empty list of meta-data.", () => {
expect(getEffectiveFinalMetaData([], DEFAULT_ENV)).toSubsetEqualRight([]);
});
test("Non-empty active list of meta-data with unavailable ENV.", () => {
expect(
getEffectiveFinalMetaData(
[{ active: true, key: "<<UNKNOWN_KEY>>", value: "<<UNKNOWN_VALUE>>" }],
DEFAULT_ENV
)
).toSubsetEqualRight([{ active: true, key: "", value: "" }]);
});
test("Inactive list of meta-data.", () => {
expect(
getEffectiveFinalMetaData(
[{ active: false, key: "KEY", value: "<<PARAM>>" }],
DEFAULT_ENV
)
).toSubsetEqualRight([]);
});
test("Active list of meta-data.", () => {
expect(
getEffectiveFinalMetaData(
[{ active: true, key: "PARAM", value: "<<PARAM>>" }],
DEFAULT_ENV
)
).toSubsetEqualRight([
{ active: true, key: "PARAM", value: "parsed_param" },
]);
});
});