Skip to content
This repository was archived by the owner on Mar 17, 2024. It is now read-only.

Commit 924f102

Browse files
committed
Removed tests not directly related to functionality provided by this package
1 parent 12500ff commit 924f102

File tree

2 files changed

+2
-72
lines changed

2 files changed

+2
-72
lines changed

e2e/plugin-test/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
"license": "Apache-2.0",
1212
"devDependencies": {
1313
"@nut-tree/nut-js": "next",
14-
"@nut-tree/template-matcher": "file:../../",
15-
"node-abort-controller": "2.0.0"
14+
"@nut-tree/template-matcher": "file:../../"
1615
}
1716
}

e2e/plugin-test/screen.class.e2e.spec.ts

Lines changed: 1 addition & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
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";
43

54
import "@nut-tree/template-matcher";
65

@@ -79,72 +78,4 @@ describe("Screen.", () => {
7978
});
8079
});
8180
});
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-
});
15081
});

0 commit comments

Comments
 (0)