mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fixing log-search tests
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
d598ee5c37
commit
efc79729c4
@ -63,13 +63,28 @@ const getOnePodViewModel = (tabId: TabId, deps: Partial<LogTabViewModelDependenc
|
|||||||
|
|
||||||
describe("LogSearch tests", () => {
|
describe("LogSearch tests", () => {
|
||||||
let render: DiRender;
|
let render: DiRender;
|
||||||
|
let setPrevOverlayActiveMock: jest.SpyInstance<void, []>;
|
||||||
|
let setNextOverlayActiveMock: jest.SpyInstance<void, []>;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
const di = getDiForUnitTesting({ doGeneralOverrides: true });
|
const di = getDiForUnitTesting({ doGeneralOverrides: true });
|
||||||
|
|
||||||
|
setPrevOverlayActiveMock = jest
|
||||||
|
.spyOn(SearchStore.prototype, "setPrevOverlayActive")
|
||||||
|
.mockImplementation(() => jest.fn());
|
||||||
|
|
||||||
|
setNextOverlayActiveMock = jest
|
||||||
|
.spyOn(SearchStore.prototype, "setNextOverlayActive")
|
||||||
|
.mockImplementation(() => jest.fn());
|
||||||
|
|
||||||
render = renderFor(di);
|
render = renderFor(di);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
setNextOverlayActiveMock.mockClear();
|
||||||
|
setPrevOverlayActiveMock.mockClear();
|
||||||
|
});
|
||||||
|
|
||||||
it("renders w/o errors", () => {
|
it("renders w/o errors", () => {
|
||||||
const model = getOnePodViewModel("foobar");
|
const model = getOnePodViewModel("foobar");
|
||||||
const { container } = render(
|
const { container } = render(
|
||||||
@ -80,7 +95,6 @@ describe("LogSearch tests", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should scroll to new active overlay when clicking the previous button", async () => {
|
it("should scroll to new active overlay when clicking the previous button", async () => {
|
||||||
const scrollToOverlay = jest.fn();
|
|
||||||
const model = getOnePodViewModel("foobar", {
|
const model = getOnePodViewModel("foobar", {
|
||||||
getLogsWithoutTimestamps: () => [
|
getLogsWithoutTimestamps: () => [
|
||||||
"hello",
|
"hello",
|
||||||
@ -91,15 +105,14 @@ describe("LogSearch tests", () => {
|
|||||||
render(
|
render(
|
||||||
<LogSearch model={model}/>,
|
<LogSearch model={model}/>,
|
||||||
);
|
);
|
||||||
|
|
||||||
userEvent.click(await screen.findByPlaceholderText("Search..."));
|
userEvent.click(await screen.findByPlaceholderText("Search..."));
|
||||||
userEvent.keyboard("o");
|
userEvent.keyboard("o");
|
||||||
userEvent.click(await screen.findByText("keyboard_arrow_up"));
|
userEvent.click(await screen.findByText("keyboard_arrow_up"));
|
||||||
expect(scrollToOverlay).toBeCalled();
|
expect(setPrevOverlayActiveMock).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should scroll to new active overlay when clicking the next button", async () => {
|
it("should scroll to new active overlay when clicking the next button", async () => {
|
||||||
const scrollToOverlay = jest.fn();
|
|
||||||
const model = getOnePodViewModel("foobar", {
|
const model = getOnePodViewModel("foobar", {
|
||||||
getLogsWithoutTimestamps: () => [
|
getLogsWithoutTimestamps: () => [
|
||||||
"hello",
|
"hello",
|
||||||
@ -114,11 +127,10 @@ describe("LogSearch tests", () => {
|
|||||||
userEvent.click(await screen.findByPlaceholderText("Search..."));
|
userEvent.click(await screen.findByPlaceholderText("Search..."));
|
||||||
userEvent.keyboard("o");
|
userEvent.keyboard("o");
|
||||||
userEvent.click(await screen.findByText("keyboard_arrow_down"));
|
userEvent.click(await screen.findByText("keyboard_arrow_down"));
|
||||||
expect(scrollToOverlay).toBeCalled();
|
expect(setNextOverlayActiveMock).toBeCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("next and previous should be disabled initially", async () => {
|
it("next and previous should be disabled initially", async () => {
|
||||||
const scrollToOverlay = jest.fn();
|
|
||||||
const model = getOnePodViewModel("foobar", {
|
const model = getOnePodViewModel("foobar", {
|
||||||
getLogsWithoutTimestamps: () => [
|
getLogsWithoutTimestamps: () => [
|
||||||
"hello",
|
"hello",
|
||||||
@ -132,6 +144,7 @@ describe("LogSearch tests", () => {
|
|||||||
|
|
||||||
userEvent.click(await screen.findByText("keyboard_arrow_down"));
|
userEvent.click(await screen.findByText("keyboard_arrow_down"));
|
||||||
userEvent.click(await screen.findByText("keyboard_arrow_up"));
|
userEvent.click(await screen.findByText("keyboard_arrow_up"));
|
||||||
expect(scrollToOverlay).not.toBeCalled();
|
expect(setNextOverlayActiveMock).not.toBeCalled();
|
||||||
|
expect(setPrevOverlayActiveMock).not.toBeCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user