|
5 | 5 | * Copyright: (c) 2020 Benny A. Daon - benny@tuzig.com |
6 | 6 | * License: GPLv3 |
7 | 7 | */ |
8 | | -import { Gate } from '../src/gate' |
9 | | -import { Terminal7Mock } from './infra' |
10 | | -import { Preferences } from '@capacitor/preferences' |
11 | | -import { vi, describe, beforeEach, afterEach, it, expect } from 'vitest' |
12 | | - |
| 8 | +import { Gate } from "../src/gate"; |
| 9 | +import { Terminal7Mock } from "./infra"; |
| 10 | +import { Preferences } from "@capacitor/preferences"; |
| 11 | +import { vi, describe, beforeEach, afterEach, it, expect } from "vitest"; |
13 | 12 |
|
14 | 13 | describe("pane", () => { |
15 | | - var t, e, h, w, p0 |
| 14 | + var t, e, h, w, p0; |
16 | 15 | beforeEach(async () => { |
17 | | - await Preferences.clear() |
18 | | - console.log("before each") |
| 16 | + await Preferences.clear(); |
| 17 | + console.log("before each"); |
19 | 18 | Gate.prototype.getCreds = function () { |
20 | | - this.completeConnect("BADWOLF") |
21 | | - } |
22 | | - t = new Terminal7Mock() |
23 | | - e = document.getElementById("t7") |
24 | | - terminal7=t |
25 | | - t.open(e) |
26 | | - h = t.addGate() |
27 | | - h.open(e) |
28 | | - w = h.addWindow("1,2,3 testing", true) |
29 | | - w.activeP.sx = 0.8 |
30 | | - w.activeP.sy = 0.6 |
31 | | - w.activeP.xoff = 0.1 |
32 | | - w.activeP.yoff = 0.2 |
33 | | - p0 = w.activeP |
34 | | - await p0.fit() |
35 | | - Preferences.set({ key: 'first_copymode', value: "1" }) |
36 | | - }) |
37 | | - afterEach(() => t && t.clearTimeouts()) |
| 19 | + this.completeConnect("BADWOLF"); |
| 20 | + }; |
| 21 | + t = new Terminal7Mock(); |
| 22 | + e = document.getElementById("t7"); |
| 23 | + terminal7 = t; |
| 24 | + t.open(e); |
| 25 | + h = t.addGate(); |
| 26 | + h.open(e); |
| 27 | + w = h.addWindow("1,2,3 testing", true); |
| 28 | + w.activeP.sx = 0.8; |
| 29 | + w.activeP.sy = 0.6; |
| 30 | + w.activeP.xoff = 0.1; |
| 31 | + w.activeP.yoff = 0.2; |
| 32 | + p0 = w.activeP; |
| 33 | + await p0.fit(); |
| 34 | + Preferences.set({ key: "first_copymode", value: "1" }); |
| 35 | + }); |
| 36 | + afterEach(() => t && t.clearTimeouts()); |
| 37 | + it("removes invisible class from gate element on unzoom", () => { |
| 38 | + // Simulate zoom then unzoom, with invisible class added to gate |
| 39 | + p0.zoom(); |
| 40 | + expect(p0.zoomed).toBeTruthy(); |
| 41 | + // Simulate what gate.focus() does: replace hidden with invisible |
| 42 | + p0.gate.e.classList.remove("hidden"); |
| 43 | + p0.gate.e.classList.add("invisible"); |
| 44 | + p0.unzoom(); |
| 45 | + expect(p0.gate.e.classList.contains("hidden")).toBeFalsy(); |
| 46 | + expect(p0.gate.e.classList.contains("invisible")).toBeFalsy(); |
| 47 | + }); |
38 | 48 | it("can forward jump words in copy mode", () => { |
39 | | - p0.t.setBuffer(["aaa aa a--.a,, -a ", "aa a"]) |
40 | | - p0.enterCopyMode(false) |
41 | | - p0.handleCMKey('w') |
42 | | - expect(p0.cmCursor.x).equal(4) |
43 | | - p0.handleCMKey('w') |
44 | | - expect(p0.cmCursor.x).equal(8) |
45 | | - p0.handleCMKey('w') |
46 | | - expect(p0.cmCursor.x).equal(9) |
47 | | - p0.handleCMKey('w') |
48 | | - expect(p0.cmCursor.x).equal(12) |
49 | | - p0.handleCMKey('w') |
50 | | - expect(p0.cmCursor.x).equal(13) |
51 | | - p0.handleCMKey('w') |
52 | | - expect(p0.cmCursor.x).equal(17) |
53 | | - p0.handleCMKey('w') |
54 | | - expect(p0.cmCursor.x).equal(18) |
55 | | - p0.handleCMKey('w') |
56 | | - expect(p0.cmCursor).toEqual({x: 0, y: 1}) |
57 | | - p0.handleCMKey('w') |
58 | | - expect(p0.cmCursor).toEqual({x: 3, y: 1}) |
59 | | - p0.handleCMKey('w') |
60 | | - expect(p0.cmCursor).toEqual({x: 3, y: 1}) |
61 | | - }) |
| 49 | + p0.t.setBuffer(["aaa aa a--.a,, -a ", "aa a"]); |
| 50 | + p0.enterCopyMode(false); |
| 51 | + p0.handleCMKey("w"); |
| 52 | + expect(p0.cmCursor.x).equal(4); |
| 53 | + p0.handleCMKey("w"); |
| 54 | + expect(p0.cmCursor.x).equal(8); |
| 55 | + p0.handleCMKey("w"); |
| 56 | + expect(p0.cmCursor.x).equal(9); |
| 57 | + p0.handleCMKey("w"); |
| 58 | + expect(p0.cmCursor.x).equal(12); |
| 59 | + p0.handleCMKey("w"); |
| 60 | + expect(p0.cmCursor.x).equal(13); |
| 61 | + p0.handleCMKey("w"); |
| 62 | + expect(p0.cmCursor.x).equal(17); |
| 63 | + p0.handleCMKey("w"); |
| 64 | + expect(p0.cmCursor.x).equal(18); |
| 65 | + p0.handleCMKey("w"); |
| 66 | + expect(p0.cmCursor).toEqual({ x: 0, y: 1 }); |
| 67 | + p0.handleCMKey("w"); |
| 68 | + expect(p0.cmCursor).toEqual({ x: 3, y: 1 }); |
| 69 | + p0.handleCMKey("w"); |
| 70 | + expect(p0.cmCursor).toEqual({ x: 3, y: 1 }); |
| 71 | + }); |
62 | 72 | it("can backward jump words in copy mode", () => { |
63 | | - p0.t.buffer.active.cursorX = 3 |
64 | | - p0.t.buffer.active.cursorY = 1 |
65 | | - p0.t.setBuffer(["aaa aa a--.a,, -a ", "aa a"]) |
66 | | - p0.enterCopyMode(false) |
67 | | - p0.handleCMKey('b') |
68 | | - expect(p0.cmCursor).toEqual({x: 0, y: 1}) |
69 | | - p0.handleCMKey('b') |
70 | | - expect(p0.cmCursor).toEqual({x: 18, y: 0}) |
71 | | - p0.handleCMKey('b') |
72 | | - expect(p0.cmCursor.x).equal(17) |
73 | | - p0.handleCMKey('b') |
74 | | - expect(p0.cmCursor.x).equal(13) |
75 | | - p0.handleCMKey('b') |
76 | | - expect(p0.cmCursor.x).equal(12) |
77 | | - p0.handleCMKey('b') |
78 | | - expect(p0.cmCursor.x).equal(9) |
79 | | - p0.handleCMKey('b') |
80 | | - expect(p0.cmCursor.x).equal(8) |
81 | | - p0.handleCMKey('b') |
82 | | - expect(p0.cmCursor.x).equal(4) |
83 | | - p0.handleCMKey('b') |
84 | | - expect(p0.cmCursor).toEqual({x: 0, y: 0}) |
85 | | - p0.handleCMKey('b') |
86 | | - expect(p0.cmCursor).toEqual({x: 0, y: 0}) |
87 | | - }) |
| 73 | + p0.t.buffer.active.cursorX = 3; |
| 74 | + p0.t.buffer.active.cursorY = 1; |
| 75 | + p0.t.setBuffer(["aaa aa a--.a,, -a ", "aa a"]); |
| 76 | + p0.enterCopyMode(false); |
| 77 | + p0.handleCMKey("b"); |
| 78 | + expect(p0.cmCursor).toEqual({ x: 0, y: 1 }); |
| 79 | + p0.handleCMKey("b"); |
| 80 | + expect(p0.cmCursor).toEqual({ x: 18, y: 0 }); |
| 81 | + p0.handleCMKey("b"); |
| 82 | + expect(p0.cmCursor.x).equal(17); |
| 83 | + p0.handleCMKey("b"); |
| 84 | + expect(p0.cmCursor.x).equal(13); |
| 85 | + p0.handleCMKey("b"); |
| 86 | + expect(p0.cmCursor.x).equal(12); |
| 87 | + p0.handleCMKey("b"); |
| 88 | + expect(p0.cmCursor.x).equal(9); |
| 89 | + p0.handleCMKey("b"); |
| 90 | + expect(p0.cmCursor.x).equal(8); |
| 91 | + p0.handleCMKey("b"); |
| 92 | + expect(p0.cmCursor.x).equal(4); |
| 93 | + p0.handleCMKey("b"); |
| 94 | + expect(p0.cmCursor).toEqual({ x: 0, y: 0 }); |
| 95 | + p0.handleCMKey("b"); |
| 96 | + expect(p0.cmCursor).toEqual({ x: 0, y: 0 }); |
| 97 | + }); |
88 | 98 | it("can jump to the end of words in copy mode", () => { |
89 | | - p0.t.setBuffer(["aaa aa a--.a,, -a ", "aa a"]) |
90 | | - p0.enterCopyMode(false) |
91 | | - p0.handleCMKey('e') |
92 | | - expect(p0.cmCursor.x).equal(2) |
93 | | - p0.handleCMKey('e') |
94 | | - expect(p0.cmCursor.x).equal(5) |
95 | | - p0.handleCMKey('e') |
96 | | - expect(p0.cmCursor.x).equal(8) |
97 | | - p0.handleCMKey('e') |
98 | | - expect(p0.cmCursor.x).equal(11) |
99 | | - p0.handleCMKey('e') |
100 | | - expect(p0.cmCursor.x).equal(12) |
101 | | - p0.handleCMKey('e') |
102 | | - expect(p0.cmCursor.x).equal(14) |
103 | | - p0.handleCMKey('e') |
104 | | - expect(p0.cmCursor.x).equal(17) |
105 | | - p0.handleCMKey('e') |
106 | | - expect(p0.cmCursor.x).equal(18) |
107 | | - p0.handleCMKey('e') |
108 | | - expect(p0.cmCursor).toEqual({x: 1, y: 1}) |
109 | | - p0.handleCMKey('e') |
110 | | - expect(p0.cmCursor).toEqual({x: 3, y: 1}) |
111 | | - p0.handleCMKey('e') |
112 | | - expect(p0.cmCursor).toEqual({x: 3, y: 1}) |
113 | | - }) |
114 | | -}) |
| 99 | + p0.t.setBuffer(["aaa aa a--.a,, -a ", "aa a"]); |
| 100 | + p0.enterCopyMode(false); |
| 101 | + p0.handleCMKey("e"); |
| 102 | + expect(p0.cmCursor.x).equal(2); |
| 103 | + p0.handleCMKey("e"); |
| 104 | + expect(p0.cmCursor.x).equal(5); |
| 105 | + p0.handleCMKey("e"); |
| 106 | + expect(p0.cmCursor.x).equal(8); |
| 107 | + p0.handleCMKey("e"); |
| 108 | + expect(p0.cmCursor.x).equal(11); |
| 109 | + p0.handleCMKey("e"); |
| 110 | + expect(p0.cmCursor.x).equal(12); |
| 111 | + p0.handleCMKey("e"); |
| 112 | + expect(p0.cmCursor.x).equal(14); |
| 113 | + p0.handleCMKey("e"); |
| 114 | + expect(p0.cmCursor.x).equal(17); |
| 115 | + p0.handleCMKey("e"); |
| 116 | + expect(p0.cmCursor.x).equal(18); |
| 117 | + p0.handleCMKey("e"); |
| 118 | + expect(p0.cmCursor).toEqual({ x: 1, y: 1 }); |
| 119 | + p0.handleCMKey("e"); |
| 120 | + expect(p0.cmCursor).toEqual({ x: 3, y: 1 }); |
| 121 | + p0.handleCMKey("e"); |
| 122 | + expect(p0.cmCursor).toEqual({ x: 3, y: 1 }); |
| 123 | + }); |
| 124 | +}); |
0 commit comments