mirror of
https://github.com/Bismuth-Forge/bismuth.git
synced 2024-09-17 11:37:10 +03:00
test(action): ✅ add focus action tests
This commit is contained in:
parent
2d2c60874c
commit
d2cb2db82a
@ -6,21 +6,87 @@
|
||||
|
||||
import { createMock } from "ts-auto-mock";
|
||||
import { Engine } from "../engine";
|
||||
import { FocusUpperWindow } from "./action";
|
||||
import { WindowsLayout } from "../engine/layout";
|
||||
import {
|
||||
FocusBottomWindow,
|
||||
FocusLeftWindow,
|
||||
FocusNextWindow,
|
||||
FocusPreviousWindow,
|
||||
FocusRightWindow,
|
||||
FocusUpperWindow,
|
||||
} from "./action";
|
||||
|
||||
describe("action", () => {
|
||||
describe("focus up", () => {
|
||||
const fakeEngine = createMock<Engine>({ focusDir: jest.fn() });
|
||||
const action = new FocusUpperWindow(fakeEngine);
|
||||
it("correctly executes", () => {
|
||||
// Arrange
|
||||
jest.spyOn(fakeEngine, "focusDir");
|
||||
describe("focus", () => {
|
||||
let fakeEngine: Engine;
|
||||
beforeEach(() => {
|
||||
fakeEngine = createMock<Engine>({
|
||||
focusDir: jest.fn(),
|
||||
focusOrder: jest.fn(),
|
||||
currentLayoutOnCurrentSurface: jest
|
||||
.fn()
|
||||
.mockReturnValue(createMock<WindowsLayout>()),
|
||||
});
|
||||
});
|
||||
|
||||
// Act
|
||||
action.execute();
|
||||
describe("up", () => {
|
||||
it("correctly executes", () => {
|
||||
const action = new FocusUpperWindow(fakeEngine);
|
||||
|
||||
// Assert
|
||||
expect(fakeEngine.focusDir).toBeCalledWith("up");
|
||||
action.execute();
|
||||
|
||||
expect(fakeEngine.focusDir).toBeCalledWith("up");
|
||||
});
|
||||
});
|
||||
|
||||
describe("down", () => {
|
||||
it("correctly executes", () => {
|
||||
const action = new FocusBottomWindow(fakeEngine);
|
||||
|
||||
action.execute();
|
||||
|
||||
expect(fakeEngine.focusDir).toBeCalledWith("down");
|
||||
});
|
||||
});
|
||||
|
||||
describe("left", () => {
|
||||
it("correctly executes", () => {
|
||||
const action = new FocusLeftWindow(fakeEngine);
|
||||
|
||||
action.execute();
|
||||
|
||||
expect(fakeEngine.focusDir).toBeCalledWith("left");
|
||||
});
|
||||
});
|
||||
|
||||
describe("right", () => {
|
||||
it("correctly executes", () => {
|
||||
const action = new FocusRightWindow(fakeEngine);
|
||||
|
||||
action.execute();
|
||||
|
||||
expect(fakeEngine.focusDir).toBeCalledWith("right");
|
||||
});
|
||||
});
|
||||
|
||||
describe("next", () => {
|
||||
it("correctly executes", () => {
|
||||
const action = new FocusNextWindow(fakeEngine);
|
||||
|
||||
action.execute();
|
||||
|
||||
expect(fakeEngine.focusOrder).toBeCalledWith(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe("prev", () => {
|
||||
it("correctly executes", () => {
|
||||
const action = new FocusPreviousWindow(fakeEngine);
|
||||
|
||||
action.execute();
|
||||
|
||||
expect(fakeEngine.focusOrder).toBeCalledWith(-1);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user