@panyam/tsappkit-solid 0.0.1 → 0.0.3
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 +6 -4
- package/src/SolidIsland.test.tsx +0 -48
- package/src/signalView.test.ts +0 -19
- package/src/smoke.test.tsx +0 -22
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@panyam/tsappkit-solid",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "Solid adapter for @panyam/tsappkit: mount Solid islands inside the tsappkit component lifecycle. The framework-specific reactivity lives here so tsappkit core stays framework-neutral.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -14,7 +14,9 @@
|
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
16
16
|
"dist",
|
|
17
|
-
"src"
|
|
17
|
+
"src",
|
|
18
|
+
"!src/**/*.test.ts",
|
|
19
|
+
"!src/**/*.test.tsx"
|
|
18
20
|
],
|
|
19
21
|
"scripts": {
|
|
20
22
|
"build": "tsup",
|
|
@@ -36,11 +38,11 @@
|
|
|
36
38
|
"author": "panyam",
|
|
37
39
|
"license": "MIT",
|
|
38
40
|
"peerDependencies": {
|
|
39
|
-
"@panyam/tsappkit": "^0.0.5",
|
|
41
|
+
"@panyam/tsappkit": "^0.0.5 || ^0.1.0 || ^0.2.0",
|
|
40
42
|
"solid-js": "^1.9.0"
|
|
41
43
|
},
|
|
42
44
|
"devDependencies": {
|
|
43
|
-
"@panyam/tsappkit": "^0.0
|
|
45
|
+
"@panyam/tsappkit": "^0.1.0",
|
|
44
46
|
"@solidjs/testing-library": "^0.8.10",
|
|
45
47
|
"esbuild-plugin-solid": "^0.6.0",
|
|
46
48
|
"jsdom": "^29.1.1",
|
package/src/SolidIsland.test.tsx
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi } from 'vitest';
|
|
2
|
-
import { createSignal, onCleanup, type JSX } from 'solid-js';
|
|
3
|
-
import { SolidIsland } from './SolidIsland';
|
|
4
|
-
|
|
5
|
-
function mount(renderRoot: () => JSX.Element) {
|
|
6
|
-
const root = document.createElement('div');
|
|
7
|
-
document.body.appendChild(root);
|
|
8
|
-
const island = new SolidIsland('test-island', root, renderRoot);
|
|
9
|
-
return { root, island };
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
describe('SolidIsland', () => {
|
|
13
|
-
it('mounts the Solid tree on activate', () => {
|
|
14
|
-
const { root, island } = mount(() => <span data-testid="hi">hello</span>);
|
|
15
|
-
expect(root.textContent).toBe('');
|
|
16
|
-
island.activate();
|
|
17
|
-
expect(root.querySelector('[data-testid="hi"]')?.textContent).toBe('hello');
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it('re-renders on signal update while mounted', () => {
|
|
21
|
-
const [count, setCount] = createSignal(0);
|
|
22
|
-
const { root, island } = mount(() => <span data-testid="n">{count()}</span>);
|
|
23
|
-
island.activate();
|
|
24
|
-
expect(root.querySelector('[data-testid="n"]')?.textContent).toBe('0');
|
|
25
|
-
setCount(2);
|
|
26
|
-
expect(root.querySelector('[data-testid="n"]')?.textContent).toBe('2');
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('disposes on deactivate: runs onCleanup and removes nodes', () => {
|
|
30
|
-
const cleanup = vi.fn();
|
|
31
|
-
const { root, island } = mount(() => {
|
|
32
|
-
onCleanup(cleanup);
|
|
33
|
-
return <span data-testid="x">x</span>;
|
|
34
|
-
});
|
|
35
|
-
island.activate();
|
|
36
|
-
expect(root.querySelector('[data-testid="x"]')).not.toBeNull();
|
|
37
|
-
island.deactivate();
|
|
38
|
-
expect(cleanup).toHaveBeenCalledTimes(1);
|
|
39
|
-
expect(root.querySelector('[data-testid="x"]')).toBeNull();
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it('is idempotent on repeated activate', () => {
|
|
43
|
-
const { root, island } = mount(() => <span data-testid="one">one</span>);
|
|
44
|
-
island.activate();
|
|
45
|
-
island.activate();
|
|
46
|
-
expect(root.querySelectorAll('[data-testid="one"]').length).toBe(1);
|
|
47
|
-
});
|
|
48
|
-
});
|
package/src/signalView.test.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { signalView } from './signalView';
|
|
3
|
-
|
|
4
|
-
describe('signalView', () => {
|
|
5
|
-
it('updates the accessor when set is called', () => {
|
|
6
|
-
const [value, set] = signalView({ terrain: 0 });
|
|
7
|
-
expect(value()).toEqual({ terrain: 0 });
|
|
8
|
-
set({ terrain: 5 });
|
|
9
|
-
expect(value()).toEqual({ terrain: 5 });
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it('stores a function value instead of treating it as a Solid updater', () => {
|
|
13
|
-
const fn = () => 42;
|
|
14
|
-
const [value, set] = signalView<() => number>(() => 0);
|
|
15
|
-
set(fn);
|
|
16
|
-
expect(value()).toBe(fn);
|
|
17
|
-
expect(value()()).toBe(42);
|
|
18
|
-
});
|
|
19
|
-
});
|
package/src/smoke.test.tsx
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { render } from '@solidjs/testing-library';
|
|
3
|
-
import { createSignal } from 'solid-js';
|
|
4
|
-
|
|
5
|
-
function Badge(props: { label: string }) {
|
|
6
|
-
return <span data-testid="badge">{props.label}</span>;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
describe('tsappkit-solid toolchain', () => {
|
|
10
|
-
it('compiles and renders a Solid component', () => {
|
|
11
|
-
const { getByTestId } = render(() => <Badge label="ready" />);
|
|
12
|
-
expect(getByTestId('badge').textContent).toBe('ready');
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('reacts to a signal update', () => {
|
|
16
|
-
const [count, setCount] = createSignal(0);
|
|
17
|
-
const { getByTestId } = render(() => <span data-testid="count">{count()}</span>);
|
|
18
|
-
expect(getByTestId('count').textContent).toBe('0');
|
|
19
|
-
setCount(3);
|
|
20
|
-
expect(getByTestId('count').textContent).toBe('3');
|
|
21
|
-
});
|
|
22
|
-
});
|