add possibility to pass non-generic KubeApi to forRemoteCluster (#4321)

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
Jari Kolehmainen authored and GitHub committed 2021-11-12 09:07:57 +02:00
1 parent d060459ccd
commit a86b306a48
2 files changed
+44 -11

No files matched your search

+31 -5
View File
@@ -19,13 +19,39 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
import { Pod } from "../endpoints/pods.api";
import { Pod, PodsApi } from "../endpoints/pods.api";
import { forRemoteCluster, KubeApi } from "../kube-api";
import { KubeJsonApi } from "../kube-json-api";
import { KubeObject } from "../kube-object";
describe("forRemoteCluster", () => {
it("builds api client", async (done) => {
it("builds api client for KubeObject", async () => {
const api = forRemoteCluster({
cluster: {
server: "https://127.0.0.1:6443",
},
user: {
token: "daa",
},
}, Pod);
expect(api).toBeInstanceOf(KubeApi);
});
it("builds api client for given KubeApi", async () => {
const api = forRemoteCluster({
cluster: {
server: "https://127.0.0.1:6443",
},
user: {
token: "daa",
},
}, Pod, PodsApi);
expect(api).toBeInstanceOf(PodsApi);
});
it("calls right api endpoint", async () => {
const api = forRemoteCluster({
cluster: {
server: "https://127.0.0.1:6443",
@@ -38,13 +64,13 @@ describe("forRemoteCluster", () => {
(fetch as any).mockResponse(async (request: any) => {
expect(request.url).toEqual("https://127.0.0.1:6443/api/v1/pods");
done();
return {
body: "",
body: "hello",
};
});
expect.hasAssertions();
await api.list();
});
});