refactor: cli updates (#2907)
Co-authored-by: Andrew Bastin <andrewbastin.k@gmail.com>
This commit is contained in:
@@ -1,28 +0,0 @@
|
||||
import { HoppCLIError } from "../../../types/errors";
|
||||
import { checkFile } from "../../../utils/checks";
|
||||
|
||||
import "@relmify/jest-fp-ts";
|
||||
|
||||
describe("checkFile", () => {
|
||||
test("File doesn't exists.", () => {
|
||||
return expect(
|
||||
checkFile("./src/samples/this-file-not-exists.json")()
|
||||
).resolves.toSubsetEqualLeft(<HoppCLIError>{
|
||||
code: "FILE_NOT_FOUND",
|
||||
});
|
||||
});
|
||||
|
||||
test("File not of JSON type.", () => {
|
||||
return expect(
|
||||
checkFile("./src/__tests__/samples/notjson.txt")()
|
||||
).resolves.toSubsetEqualLeft(<HoppCLIError>{
|
||||
code: "INVALID_FILE_TYPE",
|
||||
});
|
||||
});
|
||||
|
||||
test("Existing JSON file.", () => {
|
||||
return expect(
|
||||
checkFile("./src/__tests__/samples/passes.json")()
|
||||
).resolves.toBeRight();
|
||||
});
|
||||
});
|
||||
@@ -50,7 +50,7 @@ describe("collectionsRunner", () => {
|
||||
|
||||
test("Empty HoppCollection.", () => {
|
||||
return expect(
|
||||
collectionsRunner({ collections: [], envs: SAMPLE_ENVS })()
|
||||
collectionsRunner({ collections: [], envs: SAMPLE_ENVS })
|
||||
).resolves.toStrictEqual([]);
|
||||
});
|
||||
|
||||
@@ -66,7 +66,7 @@ describe("collectionsRunner", () => {
|
||||
},
|
||||
],
|
||||
envs: SAMPLE_ENVS,
|
||||
})()
|
||||
})
|
||||
).resolves.toMatchObject([]);
|
||||
});
|
||||
|
||||
@@ -84,7 +84,7 @@ describe("collectionsRunner", () => {
|
||||
},
|
||||
],
|
||||
envs: SAMPLE_ENVS,
|
||||
})()
|
||||
})
|
||||
).resolves.toMatchObject([
|
||||
{
|
||||
path: "collection/request",
|
||||
@@ -116,7 +116,7 @@ describe("collectionsRunner", () => {
|
||||
},
|
||||
],
|
||||
envs: SAMPLE_ENVS,
|
||||
})()
|
||||
})
|
||||
).resolves.toMatchObject([
|
||||
{
|
||||
path: "collection/folder/request",
|
||||
|
||||
@@ -1,22 +1,20 @@
|
||||
import { HoppCLIError } from "../../../types/errors";
|
||||
import { parseCollectionData } from "../../../utils/mutators";
|
||||
|
||||
import "@relmify/jest-fp-ts";
|
||||
|
||||
describe("parseCollectionData", () => {
|
||||
test("Reading non-existing file.", () => {
|
||||
return expect(
|
||||
parseCollectionData("./src/__tests__/samples/notexist.json")()
|
||||
).resolves.toSubsetEqualLeft(<HoppCLIError>{
|
||||
parseCollectionData("./src/__tests__/samples/notexist.json")
|
||||
).rejects.toMatchObject(<HoppCLIError>{
|
||||
code: "FILE_NOT_FOUND",
|
||||
});
|
||||
});
|
||||
|
||||
test("Unparseable JSON contents.", () => {
|
||||
return expect(
|
||||
parseCollectionData("./src/__tests__/samples/malformed-collection.json")()
|
||||
).resolves.toSubsetEqualLeft(<HoppCLIError>{
|
||||
code: "MALFORMED_COLLECTION",
|
||||
parseCollectionData("./src/__tests__/samples/malformed-collection.json")
|
||||
).rejects.toMatchObject(<HoppCLIError>{
|
||||
code: "UNKNOWN_ERROR",
|
||||
});
|
||||
});
|
||||
|
||||
@@ -24,15 +22,15 @@ describe("parseCollectionData", () => {
|
||||
return expect(
|
||||
parseCollectionData(
|
||||
"./src/__tests__/samples/malformed-collection2.json"
|
||||
)()
|
||||
).resolves.toSubsetEqualLeft(<HoppCLIError>{
|
||||
)
|
||||
).rejects.toMatchObject(<HoppCLIError>{
|
||||
code: "MALFORMED_COLLECTION",
|
||||
});
|
||||
});
|
||||
|
||||
test("Valid HoppCollection.", () => {
|
||||
return expect(
|
||||
parseCollectionData("./src/__tests__/samples/passes.json")()
|
||||
).resolves.toBeRight();
|
||||
parseCollectionData("./src/__tests__/samples/passes.json")
|
||||
).resolves.toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user