@vnejs/compatibility.canvas.layer-with-save 0.1.7 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +9 -7
- package/src/tests/save.layer.test.ts +31 -0
- package/src/tests/setup.ts +26 -0
- package/tsconfig.json +12 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vnejs/compatibility.canvas.layer-with-save",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"tsconfig.json"
|
|
19
19
|
],
|
|
20
20
|
"scripts": {
|
|
21
|
-
"test": "
|
|
21
|
+
"test": "npx @vnejs/monorepo test",
|
|
22
22
|
"build": "npx @vnejs/monorepo package",
|
|
23
23
|
"publish:major:plugin": "npm run publish:major",
|
|
24
24
|
"publish:minor:plugin": "npm run publish:minor",
|
|
@@ -30,12 +30,14 @@
|
|
|
30
30
|
"author": "",
|
|
31
31
|
"license": "ISC",
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"@vnejs/module.core": "~0.
|
|
34
|
-
"@vnejs/contracts.canvas.layer": "~0.
|
|
35
|
-
"@vnejs/contracts.save": "~0.
|
|
36
|
-
"@vnejs/shared": "~0.
|
|
33
|
+
"@vnejs/module.core": "~0.2.0",
|
|
34
|
+
"@vnejs/contracts.canvas.layer": "~0.2.0",
|
|
35
|
+
"@vnejs/contracts.save": "~0.2.0",
|
|
36
|
+
"@vnejs/shared": "~0.2.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@vnejs/configs.ts-common": "~0.
|
|
39
|
+
"@vnejs/configs.ts-common": "~0.2.0",
|
|
40
|
+
"@vnejs/configs.vitest": "~0.2.0",
|
|
41
|
+
"@vnejs/test-utils": "~0.2.0"
|
|
40
42
|
}
|
|
41
43
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
|
|
3
|
+
import { spyEvent } from "@vnejs/test-utils";
|
|
4
|
+
|
|
5
|
+
import { SUBSCRIBE_EVENTS as SETTINGS_EVENTS } from "@vnejs/contracts.core.settings";
|
|
6
|
+
import { SUBSCRIBE_EVENTS as SYSTEM_EVENTS } from "@vnejs/contracts.core.system";
|
|
7
|
+
import { CompatibilitySaveLayer } from "../index.js";
|
|
8
|
+
import { createCompatibilityTestModule, LAYER_SETTINGS, registerCompatibilityVne } from "./setup.js";
|
|
9
|
+
|
|
10
|
+
describe("CompatibilitySaveLayer", () => {
|
|
11
|
+
beforeEach(() => registerCompatibilityVne());
|
|
12
|
+
|
|
13
|
+
it("SETTINGS.CHANGED for layer width updates screenshot width", async () => {
|
|
14
|
+
const { module, observer } = createCompatibilityTestModule(CompatibilitySaveLayer);
|
|
15
|
+
|
|
16
|
+
await observer.emit(SETTINGS_EVENTS.CHANGED, { name: LAYER_SETTINGS.WIDTH, value: 800 });
|
|
17
|
+
|
|
18
|
+
expect((module as CompatibilitySaveLayer).PARAMS.SAVE.SCREENSHOT_WIDTH).toBe(400);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("SYSTEM.STARTED syncs screenshot size from shared settings", async () => {
|
|
22
|
+
const { module, observer } = createCompatibilityTestModule(CompatibilitySaveLayer, {
|
|
23
|
+
shared: { settings: { [LAYER_SETTINGS.WIDTH]: 640, [LAYER_SETTINGS.HEIGHT]: 480 } },
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
await observer.emit(SYSTEM_EVENTS.STARTED);
|
|
27
|
+
|
|
28
|
+
expect((module as CompatibilitySaveLayer).PARAMS.SAVE.SCREENSHOT_WIDTH).toBe(320);
|
|
29
|
+
expect((module as CompatibilitySaveLayer).PARAMS.SAVE.SCREENSHOT_HEIGHT).toBe(240);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { PARAMS as SAVE_PARAMS, PLUGIN_NAME as SAVE } from "@vnejs/contracts.save";
|
|
2
|
+
import { SETTINGS_KEYS as LAYER_SETTINGS, PLUGIN_NAME as LAYER } from "@vnejs/contracts.canvas.layer";
|
|
3
|
+
import { createTestModule as baseCreateTestModule, registerCoreVne, registerVnePlugin } from "@vnejs/test-utils";
|
|
4
|
+
|
|
5
|
+
export const registerCompatibilityVne = () => {
|
|
6
|
+
registerCoreVne();
|
|
7
|
+
registerVnePlugin(LAYER, { settings: LAYER_SETTINGS });
|
|
8
|
+
registerVnePlugin(SAVE, { params: SAVE_PARAMS });
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const createCompatibilityTestModule = <T extends Parameters<typeof baseCreateTestModule>[0]>(
|
|
12
|
+
ModuleClass: T,
|
|
13
|
+
options: Parameters<typeof baseCreateTestModule>[1] = {},
|
|
14
|
+
) =>
|
|
15
|
+
baseCreateTestModule(ModuleClass, {
|
|
16
|
+
shared: {
|
|
17
|
+
settings: {
|
|
18
|
+
[LAYER_SETTINGS.WIDTH]: 1920,
|
|
19
|
+
[LAYER_SETTINGS.HEIGHT]: 1080,
|
|
20
|
+
},
|
|
21
|
+
...(options.shared ?? {}),
|
|
22
|
+
},
|
|
23
|
+
...options,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export { LAYER_SETTINGS };
|
package/tsconfig.json
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"extends": "@vnejs/configs.ts-common/tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"rootDir": "src",
|
|
5
|
+
"outDir": "dist"
|
|
6
|
+
},
|
|
7
|
+
"include": [
|
|
8
|
+
"src/**/*.ts"
|
|
9
|
+
],
|
|
10
|
+
"exclude": [
|
|
11
|
+
"dist",
|
|
12
|
+
"node_modules",
|
|
13
|
+
"src/tests"
|
|
14
|
+
]
|
|
6
15
|
}
|