diff --git a/packages/debugger/src/dependency/test/collect.test.ts b/packages/debugger/src/dependency/collect.test.ts similarity index 96% rename from packages/debugger/src/dependency/test/collect.test.ts rename to packages/debugger/src/dependency/collect.test.ts index 318aeb13..20cc22ff 100644 --- a/packages/debugger/src/dependency/test/collect.test.ts +++ b/packages/debugger/src/dependency/collect.test.ts @@ -1,18 +1,18 @@ -import '../../setup.ts' +import '../setup.ts' import * as s from 'solid-js' import * as test from 'vitest' -import {NodeType} from '../../main/constants.ts' -import {ObjectType, getSdtId} from '../../main/id.ts' -import setup from '../../main/setup.ts' -import type {NodeID, Solid} from '../../main/types.ts' -import {type SerializedDGraph, collectDependencyGraph} from '../collect.ts' +import {NodeType} from '../main/constants.ts' +import {ObjectType, getSdtId} from '../main/id.ts' +import setup from '../main/setup.ts' +import type {NodeID, Solid} from '../main/types.ts' +import {type SerializedDGraph, collectDependencyGraph} from './collect.ts' let mockLAST_ID = 0 test.beforeEach(() => { mockLAST_ID = 0 }) -test.vi.mock('../../main/get-id', () => ({getNewSdtId: () => '#' + mockLAST_ID++})) +test.vi.mock('../main/get-id.ts', () => ({getNewSdtId: () => '#' + mockLAST_ID++})) test.describe('collectDependencyGraph', () => { test.it('should collect dependency graph', () => { diff --git a/packages/debugger/src/inspector/test/index.test.tsx b/packages/debugger/src/inspector/index.test.tsx similarity index 71% rename from packages/debugger/src/inspector/test/index.test.tsx rename to packages/debugger/src/inspector/index.test.tsx index a776ea72..3b73b53c 100644 --- a/packages/debugger/src/inspector/test/index.test.tsx +++ b/packages/debugger/src/inspector/index.test.tsx @@ -1,20 +1,14 @@ -import '../../setup.ts' +import '../setup.ts' import * as s from 'solid-js' -import {beforeEach, describe, expect, it, vi} from 'vitest' -import {getObjectById, getSdtId, ObjectType} from '../../main/id.ts' -import setup from '../../main/setup.ts' -import {type Mapped, NodeType, PropGetterState, type Solid, ValueType} from '../../types.ts' -import {collectOwnerDetails} from '../inspector.ts' - -let mockLAST_ID = 0 -beforeEach(() => { - mockLAST_ID = 0 -}) -vi.mock('../../main/get-id', () => ({getNewSdtId: () => '#' + mockLAST_ID++})) - -describe('collectOwnerDetails', () => { - it('collects focused owner details', () => { +import * as test from 'vitest' +import {getObjectById, getSdtId, ObjectType} from '../main/id.ts' +import setup from '../main/setup.ts' +import {type Mapped, NodeType, PropGetterState, type Solid, ValueType} from '../types.ts' +import {collectOwnerDetails} from './inspector.ts' + +test.describe('collectOwnerDetails', () => { + test.it('collects focused owner details', () => { s.createRoot(dispose => { const [source] = s.createSignal(0, {name: 'source'}) @@ -57,7 +51,7 @@ describe('collectOwnerDetails', () => { }, }) - expect(details).toEqual({ + test.expect(details).toEqual({ id: getSdtId(memo, ObjectType.Owner), name: 'focused', type: NodeType.Memo, @@ -84,26 +78,29 @@ describe('collectOwnerDetails', () => { ], } satisfies Mapped.OwnerDetails) - expect(valueMap.get(`signal:${getSdtId(customValue, ObjectType.CustomValue)}`)).toBeTruthy() - expect(valueMap.get(`signal:${getSdtId(signalB, ObjectType.Signal)}`)).toBeTruthy() - expect(valueMap.get(`signal:${getSdtId(innerMemo, ObjectType.Owner)}`)).toBeTruthy() + test.expect(valueMap.get(`signal:${getSdtId(customValue, ObjectType.CustomValue)}`)).toBeTruthy() + test.expect(valueMap.get(`signal:${getSdtId(signalB, ObjectType.Signal)}`)).toBeTruthy() + test.expect(valueMap.get(`signal:${getSdtId(innerMemo, ObjectType.Owner)}`)).toBeTruthy() - expect(getObjectById('#3', ObjectType.Element)).toBe(div) + test.expect(getObjectById('#3', ObjectType.Element)).toBe(div) dispose() }) }) - it('component props', () => { + test.it('component props', () => { s.createRoot(dispose => { + let owner!: Solid.Owner + let div_ref!: HTMLDivElement + const TestComponent = (props: { count: number children: s.JSX.Element nested: {foo: number; bar: string} }) => { owner = setup.solid.getOwner()! - return
{props.children}
+ return
{props.children}
} s.createRenderEffect(() => ( @@ -123,12 +120,12 @@ describe('collectOwnerDetails', () => { dispose() - expect(details).toEqual({ - id: '#0', + test.expect(details).toEqual({ + id: getSdtId(owner, ObjectType.Owner), name: 'TestComponent', type: NodeType.Component, signals: [], - value: [[ValueType.Element, '#1:div']], + value: [[ValueType.Element, `${getSdtId(div_ref, ObjectType.Element)}:div`]], props: { proxy: false, record: { @@ -147,14 +144,15 @@ describe('collectOwnerDetails', () => { }, }, } satisfies Mapped.OwnerDetails) - - expect(getObjectById('#1', ObjectType.Element)).toBeInstanceOf(HTMLDivElement) }) }) - it('dynamic component props', () => { + test.it('dynamic component props', () => { s.createRoot(dispose => { + let owner!: Solid.Owner + let el_ref!: HTMLDivElement + const Button = (props: s.JSX.ButtonHTMLAttributes) => { owner = setup.solid.getOwner()! return @@ -167,7 +165,7 @@ describe('collectOwnerDetails', () => { }, role: 'button', }) as const - return