@vnejs/plugins.settings.potato 0.1.15 → 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 +8 -6
- package/src/tests/potato.test.ts +44 -0
- package/src/tests/setup.ts +24 -0
- package/tsconfig.json +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vnejs/plugins.settings.potato",
|
|
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,13 +30,15 @@
|
|
|
30
30
|
"author": "",
|
|
31
31
|
"license": "ISC",
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@vnejs/contracts.settings.potato": "~0.
|
|
33
|
+
"@vnejs/contracts.settings.potato": "~0.2.0"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@vnejs/module.core": "~0.
|
|
37
|
-
"@vnejs/shared": "~0.
|
|
36
|
+
"@vnejs/module.core": "~0.2.0",
|
|
37
|
+
"@vnejs/shared": "~0.2.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@vnejs/configs.ts-common": "~0.
|
|
40
|
+
"@vnejs/configs.ts-common": "~0.2.0",
|
|
41
|
+
"@vnejs/configs.vitest": "~0.2.0",
|
|
42
|
+
"@vnejs/test-utils": "~0.2.0"
|
|
41
43
|
}
|
|
42
44
|
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it } from "vitest";
|
|
2
|
+
|
|
3
|
+
import { SUBSCRIBE_EVENTS as SETTINGS_EVENTS } from "@vnejs/contracts.core.settings";
|
|
4
|
+
import { SUBSCRIBE_EVENTS } from "@vnejs/contracts.settings.potato";
|
|
5
|
+
import { spyEvent } from "@vnejs/test-utils";
|
|
6
|
+
|
|
7
|
+
import { Potato } from "../modules/potato.js";
|
|
8
|
+
import { createPotatoTestModule, registerPotatoPluginVne, SETTINGS_KEYS } from "./setup.js";
|
|
9
|
+
|
|
10
|
+
describe("Potato", () => {
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
registerPotatoPluginVne();
|
|
13
|
+
document.head.innerHTML = "";
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("POTATO.EMIT enabled injects no-transition style", async () => {
|
|
17
|
+
const { module, observer, shared } = createPotatoTestModule(Potato);
|
|
18
|
+
|
|
19
|
+
await (module as Potato).init();
|
|
20
|
+
await observer.emit(SUBSCRIBE_EVENTS.EMIT, { value: true });
|
|
21
|
+
|
|
22
|
+
expect(document.head.querySelector("style")?.innerHTML).toContain("transition:none");
|
|
23
|
+
expect(shared.mediaNoTimeoutSources!.has((module as Potato).CONST.POTATO.SOURCE)).toBe(true);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("POTATO.EMIT disabled removes style", async () => {
|
|
27
|
+
const { module, observer } = createPotatoTestModule(Potato);
|
|
28
|
+
|
|
29
|
+
await (module as Potato).init();
|
|
30
|
+
await observer.emit(SUBSCRIBE_EVENTS.EMIT, { value: true });
|
|
31
|
+
await observer.emit(SUBSCRIBE_EVENTS.EMIT, { value: false });
|
|
32
|
+
|
|
33
|
+
expect(document.head.querySelector("style")).toBeNull();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("SETTINGS.CHANGED forwards enabled toggle", async () => {
|
|
37
|
+
const { observer } = createPotatoTestModule(Potato);
|
|
38
|
+
const emit = spyEvent(observer, SUBSCRIBE_EVENTS.EMIT);
|
|
39
|
+
|
|
40
|
+
await observer.emit(SETTINGS_EVENTS.CHANGED, { name: SETTINGS_KEYS.ENABLED, value: true });
|
|
41
|
+
|
|
42
|
+
expect(emit).toHaveBeenCalledExactlyOnceWith({ value: true });
|
|
43
|
+
});
|
|
44
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { CONSTANTS, PLUGIN_NAME, SETTINGS_KEYS, SUBSCRIBE_EVENTS } from "@vnejs/contracts.settings.potato";
|
|
2
|
+
import { createTestModule as baseCreateTestModule, registerCoreVne, registerVnePlugin } from "@vnejs/test-utils";
|
|
3
|
+
import { SourcesSet } from "@vnejs/sources-set";
|
|
4
|
+
|
|
5
|
+
export const registerPotatoPluginVne = () => {
|
|
6
|
+
registerCoreVne();
|
|
7
|
+
registerVnePlugin(PLUGIN_NAME, { constants: CONSTANTS, events: SUBSCRIBE_EVENTS, settings: SETTINGS_KEYS });
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const createPotatoTestModule = <T extends Parameters<typeof baseCreateTestModule>[0]>(
|
|
11
|
+
ModuleClass: T,
|
|
12
|
+
options: Parameters<typeof baseCreateTestModule>[1] = {},
|
|
13
|
+
) =>
|
|
14
|
+
baseCreateTestModule(ModuleClass, {
|
|
15
|
+
shared: {
|
|
16
|
+
settings: { [SETTINGS_KEYS.ENABLED]: false },
|
|
17
|
+
mediaNoTimeoutSources: new SourcesSet(),
|
|
18
|
+
viewForceAnimationSources: new SourcesSet(),
|
|
19
|
+
...(options.shared as Record<string, unknown>),
|
|
20
|
+
},
|
|
21
|
+
...options,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export { PLUGIN_NAME, SETTINGS_KEYS };
|
package/tsconfig.json
CHANGED