chore: nuke jest tests

This commit is contained in:
Mikhail Zolotukhin 2022-02-07 18:08:24 +03:00
parent c577368dff
commit 6238ce12dd
4 changed files with 0 additions and 508 deletions

View File

@ -1,5 +0,0 @@
// SPDX-FileCopyrightText: none
//
// SPDX-License-Identifier: MIT
import "jest-ts-auto-mock";

View File

@ -4,7 +4,6 @@
"description": "A dynamic tiling extension for KWin",
"private": true,
"devDependencies": {
"@types/jest": "26.0.14",
"@typescript-eslint/eslint-plugin": "5.5.0",
"@typescript-eslint/parser": "5.5.0",
"esbuild": "0.14.1",
@ -15,12 +14,8 @@
"eslint-plugin-prefer-arrow": "1.2.3",
"eslint-plugin-prettier": "4.0.0",
"husky": "7.0.4",
"jest": "26.6.3",
"jest-ts-auto-mock": "2.0.0",
"lint-staged": "12.1.2",
"prettier": "2.5.0",
"ts-auto-mock": "3.5.0",
"ts-jest": "26.5.6",
"ttypescript": "1.5.13",
"typedoc": "0.22.10",
"typedoc-plugin-missing-exports": "0.22.6",
@ -60,26 +55,6 @@
"url": "https://github.com/gikari/bismuth/issues"
},
"homepage": "https://github.com/gikari/bismuth#readme",
"jest": {
"preset": "ts-jest",
"transform": {
".(ts|tsx)": "ts-jest"
},
"testEnvironment": "node",
"globals": {
"ts-jest": {
"compiler": "ttypescript",
"setupFiles": [
"<rootDir>config.ts"
],
"diagnostics": {
"ignoreCodes": [
"TS151001"
]
}
}
}
},
"prettier": {},
"lint-staged": {
"**/*": "prettier --write --ignore-unknown",

View File

@ -1,393 +0,0 @@
// SPDX-FileCopyrightText: 2021 Mikhail Zolotukhin <mail@genda.life>
//
// SPDX-License-Identifier: MIT
/* eslint-disable @typescript-eslint/unbound-method */
import { createMock } from "ts-auto-mock";
import { Engine } from "../engine";
import { WindowsLayout } from "../engine/layout";
import { EngineWindow } from "../engine/window";
import { NullLog } from "../util/log";
import * as Action from "./action";
describe("action", () => {
const fakeLog = new NullLog();
describe("focus", () => {
let fakeEngine: Engine;
beforeEach(() => {
fakeEngine = createMock<Engine>({
focusDir: jest.fn(),
focusOrder: jest.fn(),
currentLayoutOnCurrentSurface: jest
.fn()
.mockReturnValue(createMock<WindowsLayout>()),
});
});
describe("up", () => {
it("correctly executes", () => {
const action = new Action.FocusUpperWindow(fakeEngine, fakeLog);
action.execute();
expect(fakeEngine.focusDir).toBeCalledWith("up");
});
});
describe("down", () => {
it("correctly executes", () => {
const action = new Action.FocusBottomWindow(fakeEngine, fakeLog);
action.execute();
expect(fakeEngine.focusDir).toBeCalledWith("down");
});
});
describe("left", () => {
it("correctly executes", () => {
const action = new Action.FocusLeftWindow(fakeEngine, fakeLog);
action.execute();
expect(fakeEngine.focusDir).toBeCalledWith("left");
});
});
describe("right", () => {
it("correctly executes", () => {
const action = new Action.FocusRightWindow(fakeEngine, fakeLog);
action.execute();
expect(fakeEngine.focusDir).toBeCalledWith("right");
});
});
describe("next", () => {
it("correctly executes", () => {
const action = new Action.FocusNextWindow(fakeEngine, fakeLog);
action.execute();
expect(fakeEngine.focusOrder).toBeCalledWith(1, false);
});
});
describe("prev", () => {
it("correctly executes", () => {
const action = new Action.FocusPreviousWindow(fakeEngine, fakeLog);
action.execute();
expect(fakeEngine.focusOrder).toBeCalledWith(-1, false);
});
});
});
describe("move window", () => {
let fakeEngine: Engine;
let fakeCurrentWindow: EngineWindow;
beforeEach(() => {
fakeCurrentWindow = createMock<EngineWindow>();
fakeEngine = createMock<Engine>({
swapOrder: jest.fn(),
swapDirOrMoveFloat: jest.fn(),
currentWindow: jest.fn().mockReturnValue(fakeCurrentWindow),
});
});
describe("up", () => {
it("correctly executes", () => {
const action = new Action.MoveActiveWindowUp(fakeEngine, fakeLog);
action.execute();
expect(fakeEngine.swapDirOrMoveFloat).toBeCalledWith("up");
});
});
describe("down", () => {
it("correctly executes", () => {
const action = new Action.MoveActiveWindowDown(fakeEngine, fakeLog);
action.execute();
expect(fakeEngine.swapDirOrMoveFloat).toBeCalledWith("down");
});
});
describe("left", () => {
it("correctly executes", () => {
const action = new Action.MoveActiveWindowLeft(fakeEngine, fakeLog);
action.execute();
expect(fakeEngine.swapDirOrMoveFloat).toBeCalledWith("left");
});
});
describe("right", () => {
it("correctly executes", () => {
const action = new Action.MoveActiveWindowRight(fakeEngine, fakeLog);
action.execute();
expect(fakeEngine.swapDirOrMoveFloat).toBeCalledWith("right");
});
});
describe("next", () => {
it("correctly executes", () => {
const action = new Action.MoveActiveWindowToNextPosition(
fakeEngine,
fakeLog
);
action.execute();
expect(fakeEngine.swapOrder).toBeCalledWith(fakeCurrentWindow, 1);
});
});
describe("prev", () => {
it("correctly executes", () => {
const action = new Action.MoveActiveWindowToPreviousPosition(
fakeEngine,
fakeLog
);
action.execute();
expect(fakeEngine.swapOrder).toBeCalledWith(fakeCurrentWindow, -1);
});
});
});
describe("window resize", () => {
let fakeEngine: Engine;
let fakeCurrentWindow: EngineWindow;
beforeEach(() => {
fakeCurrentWindow = createMock<EngineWindow>();
fakeEngine = createMock<Engine>({
resizeWindow: jest.fn(),
currentWindow: jest.fn().mockReturnValue(fakeCurrentWindow),
});
});
describe("width increase", () => {
it("correctly executes", () => {
const action = new Action.IncreaseActiveWindowWidth(
fakeEngine,
fakeLog
);
action.execute();
expect(fakeEngine.resizeWindow).toBeCalledWith(
fakeCurrentWindow,
"east",
1
);
});
});
describe("width decrease", () => {
it("correctly executes", () => {
const action = new Action.DecreaseActiveWindowWidth(
fakeEngine,
fakeLog
);
action.execute();
expect(fakeEngine.resizeWindow).toBeCalledWith(
fakeCurrentWindow,
"east",
-1
);
});
});
describe("height increase", () => {
it("correctly executes", () => {
const action = new Action.IncreaseActiveWindowHeight(
fakeEngine,
fakeLog
);
action.execute();
expect(fakeEngine.resizeWindow).toBeCalledWith(
fakeCurrentWindow,
"south",
1
);
});
});
describe("height decrease", () => {
it("correctly executes", () => {
const action = new Action.DecreaseActiveWindowHeight(
fakeEngine,
fakeLog
);
action.execute();
expect(fakeEngine.resizeWindow).toBeCalledWith(
fakeCurrentWindow,
"south",
-1
);
});
});
});
describe("master area", () => {
let fakeEngine: Engine;
beforeEach(() => {
fakeEngine = createMock<Engine>({
showNotification: jest.fn(),
});
});
describe("increase windows count", () => {
it("shows a note that there is no master area in general case", () => {
const action = new Action.IncreaseMasterAreaWindowCount(
fakeEngine,
fakeLog
);
action.execute();
expect(fakeEngine.showNotification).toBeCalledWith("No Master Area");
});
});
describe("decrease windows count", () => {
it("shows a note that there is no master area in general case", () => {
const action = new Action.DecreaseMasterAreaWindowCount(
fakeEngine,
fakeLog
);
action.execute();
expect(fakeEngine.showNotification).toBeCalledWith("No Master Area");
});
});
describe("increase size", () => {
it("shows a note that there is no master area in general case", () => {
const action = new Action.IncreaseLayoutMasterAreaSize(
fakeEngine,
fakeLog
);
action.execute();
expect(fakeEngine.showNotification).toBeCalledWith("No Master Area");
});
});
describe("decrease size", () => {
it("shows a note that there is no master area in general case", () => {
const action = new Action.DecreaseLayoutMasterAreaSize(
fakeEngine,
fakeLog
);
action.execute();
expect(fakeEngine.showNotification).toBeCalledWith("No Master Area");
});
});
});
describe("toggle floating", () => {
it("executes correctly", () => {
const fakeCurrentWindow = createMock<EngineWindow>();
const fakeEngine = createMock<Engine>({
toggleFloat: jest.fn(),
currentWindow: jest.fn().mockReturnValue(fakeCurrentWindow),
});
const action = new Action.ToggleActiveWindowFloating(fakeEngine, fakeLog);
action.execute();
expect(fakeEngine.toggleFloat).toBeCalledWith(fakeCurrentWindow);
});
});
describe("push window into master area", () => {
it("executes correctly", () => {
const fakeCurrentWindow = createMock<EngineWindow>();
const fakeEngine = createMock<Engine>({
setMaster: jest.fn(),
currentWindow: jest.fn().mockReturnValue(fakeCurrentWindow),
});
const action = new Action.PushActiveWindowIntoMasterAreaFront(
fakeEngine,
fakeLog
);
action.execute();
expect(fakeEngine.setMaster).toBeCalledWith(fakeCurrentWindow);
});
});
describe("layout switching", () => {
let fakeEngine: Engine;
let fakeCurrentWindow: EngineWindow;
beforeEach(() => {
fakeCurrentWindow = createMock<EngineWindow>();
fakeEngine = createMock<Engine>({
cycleLayout: jest.fn(),
toggleLayout: jest.fn(),
currentWindow: jest.fn().mockReturnValue(fakeCurrentWindow),
});
});
describe("next layout", () => {
it("executes correctly", () => {
const action = new Action.SwitchToNextLayout(fakeEngine, fakeLog);
action.execute();
expect(fakeEngine.cycleLayout).toBeCalledWith(1);
});
});
describe("prev layout", () => {
it("executes correctly", () => {
const action = new Action.SwitchToPreviousLayout(fakeEngine, fakeLog);
action.execute();
expect(fakeEngine.cycleLayout).toBeCalledWith(-1);
});
});
describe("set layout", () => {
it("executes correctly when asking to set Monocle Layout", () => {
const action = new Action.ToggleMonocleLayout(fakeEngine, fakeLog);
action.execute();
expect(fakeEngine.toggleLayout).toBeCalledWith("MonocleLayout");
});
});
});
});

View File

@ -1,85 +0,0 @@
// SPDX-FileCopyrightText: 2021 Mikhail Zolotukhin <mail@genda.life>
//
// SPDX-License-Identifier: MIT
/* eslint-disable @typescript-eslint/unbound-method */
import { createMock } from "ts-auto-mock";
import { EngineImpl } from ".";
import { Config } from "../config";
import { Controller } from "../controller";
import { DriverSurface } from "../driver/surface";
import { Log } from "../util/log";
import { Rect } from "../util/rect";
import TileLayout from "./layout/tile_layout";
import LayoutStore from "./layout_store";
import { EngineWindow, WindowState } from "./window";
import { WindowStore } from "./window_store";
describe("arrange", () => {
it("happens on all screens", () => {
// Arrange
const screenMock = createMock<DriverSurface>();
const fakeScreens = [screenMock, screenMock, screenMock, screenMock];
const controllerMock = createMock<Controller>({ screens: fakeScreens });
const logMock = createMock<Log>();
const configMock = createMock<Config>();
const engine = new EngineImpl(controllerMock, configMock, logMock);
jest.spyOn(engine, "arrangeScreen").mockReturnValue();
// Act
engine.arrange();
// Assert
expect(engine.arrangeScreen).toBeCalledTimes(4);
});
});
describe("arrangeScreen", () => {
describe("window states are correctly changed", () => {
// Arrange
const controllerMock = createMock<Controller>();
const logMock = createMock<Log>();
const configMock = createMock<Config>();
const engine = new EngineImpl(controllerMock, configMock, logMock);
const window1 = createMock<EngineWindow>({
shouldFloat: false,
state: WindowState.Undecided,
});
const window2 = createMock<EngineWindow>({
shouldFloat: true,
state: WindowState.Undecided,
});
engine.windows = createMock<WindowStore>({
visibleWindowsOn: () => [window1, window2],
visibleTileableWindowsOn: () => [],
});
engine.layouts = createMock<LayoutStore>({
getCurrentLayout: () => createMock<TileLayout>(),
});
jest
.spyOn(EngineImpl.prototype as any, "getTilingArea")
.mockReturnValue(createMock<Rect>());
const mockSurface = createMock<DriverSurface>();
// Act
engine.arrangeScreen(mockSurface);
// Assert
it("sets all undecided windows to tiled state, when they should not float", () => {
expect(window1.state).toEqual(WindowState.Tiled);
});
it("sets all undecided windows to float state, when they should float", () => {
expect(window2.state).toEqual(WindowState.Floating);
});
});
});