|
1 | 1 | import {existsSync} from "fs";
|
2 |
| -import {screen, sleep, FileType, Region} from "@nut-tree/nut-js"; |
3 |
| -import AbortController from "node-abort-controller"; |
| 2 | +import {FileType, screen, sleep} from "@nut-tree/nut-js"; |
4 | 3 |
|
5 | 4 | import "@nut-tree/template-matcher";
|
6 | 5 |
|
@@ -79,72 +78,4 @@ describe("Screen.", () => {
|
79 | 78 | });
|
80 | 79 | });
|
81 | 80 | });
|
82 |
| - |
83 |
| - it("should reject after timeout", async () => { |
84 |
| - // GIVEN |
85 |
| - const timeout = 5000; |
86 |
| - screen.config.resourceDirectory = "./e2e/assets"; |
87 |
| - |
88 |
| - // WHEN |
89 |
| - const start = Date.now(); |
90 |
| - try { |
91 |
| - await screen.waitFor("calculator.png", timeout); |
92 |
| - } catch (e) { |
93 |
| - // THEN |
94 |
| - expect(e).toBe(`Action timed out after ${timeout} ms`); |
95 |
| - } |
96 |
| - const end = Date.now(); |
97 |
| - |
98 |
| - // THEN |
99 |
| - expect(end - start).toBeGreaterThanOrEqual(timeout); |
100 |
| - }); |
101 |
| - |
102 |
| - it("should abort via signal", (done) => { |
103 |
| - // GIVEN |
104 |
| - const timeout = 5000; |
105 |
| - const abortAfterMs = 1000; |
106 |
| - const controller = new AbortController(); |
107 |
| - const signal = controller.signal; |
108 |
| - screen.config.resourceDirectory = "./e2e/assets"; |
109 |
| - |
110 |
| - // WHEN |
111 |
| - const start = Date.now(); |
112 |
| - screen.waitFor("calculator.png", timeout, {abort: signal}).catch(e => { |
113 |
| - const end = Date.now(); |
114 |
| - |
115 |
| - // THEN |
116 |
| - expect(e).toBe(`Action aborted by signal`); |
117 |
| - expect(end - start).toBeGreaterThanOrEqual(abortAfterMs); |
118 |
| - expect(end - start).toBeLessThan(timeout); |
119 |
| - done(); |
120 |
| - }); |
121 |
| - setTimeout(() => controller.abort(), abortAfterMs); |
122 |
| - }); |
123 |
| - |
124 |
| - it("should grab the whole screen content and return an Image", async () => { |
125 |
| - // GIVEN |
126 |
| - const screenWidth = await screen.width(); |
127 |
| - const screenHeight = await screen.height(); |
128 |
| - |
129 |
| - // WHEN |
130 |
| - const image = await screen.grab(); |
131 |
| - |
132 |
| - // THEN |
133 |
| - expect(image.data).not.toBeUndefined(); |
134 |
| - expect(image.width / image.pixelDensity.scaleX).toBe(screenWidth); |
135 |
| - expect(image.height / image.pixelDensity.scaleY).toBe(screenHeight); |
136 |
| - }); |
137 |
| - |
138 |
| - it("should grab a screen region and return an Image", async () => { |
139 |
| - // GIVEN |
140 |
| - const regionToGrab = new Region(0, 0, 100, 100); |
141 |
| - |
142 |
| - // WHEN |
143 |
| - const image = await screen.grabRegion(regionToGrab); |
144 |
| - |
145 |
| - // THEN |
146 |
| - expect(image.data).not.toBeUndefined(); |
147 |
| - expect(image.width / image.pixelDensity.scaleX).toBe(regionToGrab.width); |
148 |
| - expect(image.height / image.pixelDensity.scaleY).toBe(regionToGrab.height); |
149 |
| - }); |
150 | 81 | });
|
0 commit comments