Catch empty string error is parseKubeApi (#3358)

* Catch empty string error is parseKubeApi

- Add more debugging lines

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Add some unit tests

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Use resolved pathname

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton authored and GitHub committed 2021-07-14 08:48:32 +03:00
1 parent 2059034eab
commit f2cd0aa8e8
4 files changed
+54 -11

No files matched your search

@@ -129,8 +129,18 @@ const tests: KubeApiParseTestData[] = [
}],
];
const throwtests = [
undefined,
"",
"ajklsmh"
];
describe("parseApi unit tests", () => {
it.each(tests)("testing %s", (url, expected) => {
it.each(tests)("testing %j", (url, expected) => {
expect(parseKubeApi(url)).toStrictEqual(expected);
});
it.each(throwtests)("testing %j should throw", (url) => {
expect(() => parseKubeApi(url)).toThrowError("invalid apiPath");
});
});