Files
hoppscotch/packages/hoppscotch-cli/src/__tests__/functions/getters/getEffectiveFinalMetaData.spec.ts
Deepanshu Dhruw 432337b801 chore: tests for hoppscotch-cli (#2300)
Co-authored-by: Andrew Bastin <andrewbastin.k@gmail.com>
2022-05-11 15:44:19 +05:30

43 lines
1.2 KiB
TypeScript

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" },
]);
});
});