mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Initial PodDetailsList tests
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
4af8fbaa34
commit
12920c89f9
@ -0,0 +1,9 @@
|
|||||||
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
|
exports[`<PodDetailsList /> when no pods passed and podStore is loaded renders 1`] = `
|
||||||
|
<div>
|
||||||
|
<div>
|
||||||
|
No items found
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
@ -0,0 +1,61 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import type { AsyncFnMock } from "@async-fn/jest";
|
||||||
|
import asyncFn from "@async-fn/jest";
|
||||||
|
import type { DiContainer } from "@ogre-tools/injectable";
|
||||||
|
import React from "react";
|
||||||
|
import fetchInjectable, { Fetch } from "../../../../common/fetch/fetch.injectable";
|
||||||
|
import { getDiForUnitTesting } from "../../../getDiForUnitTesting";
|
||||||
|
import storesAndApisCanBeCreatedInjectable from "../../../stores-apis-can-be-created.injectable";
|
||||||
|
import { DiRender, renderFor } from "../../test-utils/renderFor";
|
||||||
|
import { PodDetailsList } from "../pod-details-list";
|
||||||
|
import type { PodStore } from "../store";
|
||||||
|
import podStoreInjectable from "../store.injectable";
|
||||||
|
|
||||||
|
describe("<PodDetailsList />", () => {
|
||||||
|
let di: DiContainer;
|
||||||
|
let podStore: PodStore;
|
||||||
|
let render: DiRender;
|
||||||
|
let fetchMock: AsyncFnMock<Fetch>;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
di = getDiForUnitTesting({ doGeneralOverrides: true });
|
||||||
|
di.override(storesAndApisCanBeCreatedInjectable, () => true);
|
||||||
|
|
||||||
|
fetchMock = asyncFn();
|
||||||
|
podStore = di.inject(podStoreInjectable);
|
||||||
|
|
||||||
|
di.override(fetchInjectable, () => fetchMock);
|
||||||
|
|
||||||
|
render = renderFor(di);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("when no pods passed and podStore is loaded", () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
podStore.isLoaded = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
it("renders", () => {
|
||||||
|
const result = render(
|
||||||
|
<PodDetailsList
|
||||||
|
pods={[]}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(result.container).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("shows empty message", () => {
|
||||||
|
const result = render(
|
||||||
|
<PodDetailsList
|
||||||
|
pods={[]}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(result.getByText("No items found")).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
Loading…
Reference in New Issue
Block a user