@olane/o-test 0.7.12 → 0.7.13-alpha.1

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.
@@ -1,7 +1,13 @@
1
1
  /**
2
- * Test builders - Fluent APIs for common test scenarios
2
+ * Test builders - MOVED
3
+ *
4
+ * These builders have been moved to @olane/o-node/test/helpers to break circular dependencies.
5
+ *
6
+ * To use these builders, import from:
7
+ * ```typescript
8
+ * import { TestEnvironment, SimpleNodeBuilder, LeaderChildBuilder, ManagerWorkerBuilder } from '@olane/o-node/test/helpers';
9
+ * ```
10
+ *
11
+ * The source files remain in this directory for reference but are no longer exported.
3
12
  */
4
- export { SimpleNodeBuilder } from './simple-node-builder.js';
5
- export { LeaderChildBuilder, type LeaderConfig } from './leader-child-builder.js';
6
- export { ManagerWorkerBuilder, type ManagerWorkerResult } from './manager-worker-builder.js';
7
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/builders/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,KAAK,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAClF,OAAO,EAAE,oBAAoB,EAAE,KAAK,mBAAmB,EAAE,MAAM,6BAA6B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/builders/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG"}
@@ -1,6 +1,13 @@
1
+ "use strict";
1
2
  /**
2
- * Test builders - Fluent APIs for common test scenarios
3
+ * Test builders - MOVED
4
+ *
5
+ * These builders have been moved to @olane/o-node/test/helpers to break circular dependencies.
6
+ *
7
+ * To use these builders, import from:
8
+ * ```typescript
9
+ * import { TestEnvironment, SimpleNodeBuilder, LeaderChildBuilder, ManagerWorkerBuilder } from '@olane/o-node/test/helpers';
10
+ * ```
11
+ *
12
+ * The source files remain in this directory for reference but are no longer exported.
3
13
  */
4
- export { SimpleNodeBuilder } from './simple-node-builder.js';
5
- export { LeaderChildBuilder } from './leader-child-builder.js';
6
- export { ManagerWorkerBuilder } from './manager-worker-builder.js';
@@ -9,10 +9,10 @@
9
9
  * .build(env);
10
10
  * ```
11
11
  */
12
- import type { oNode, oNodeAddress } from '@olane/o-node';
12
+ import type { oNodeAddress, oNodeTool } from '@olane/o-node';
13
13
  import type { TestEnvironment } from '../test-environment.js';
14
14
  import type { TestNodeConfig } from '../test-environment.js';
15
- export declare class SimpleNodeBuilder<T extends oNode = any> {
15
+ export declare class SimpleNodeBuilder<T extends oNodeTool = any> {
16
16
  private nodeClass;
17
17
  private config;
18
18
  private autoStart;
@@ -24,7 +24,7 @@ export declare class SimpleNodeBuilder<T extends oNode = any> {
24
24
  /**
25
25
  * Set node address
26
26
  */
27
- withAddress(address: string | oNodeAddress): this;
27
+ withAddress(address: oNodeAddress): this;
28
28
  /**
29
29
  * Set node description
30
30
  */
@@ -1 +1 @@
1
- {"version":3,"file":"simple-node-builder.d.ts","sourceRoot":"","sources":["../../../src/builders/simple-node-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE7D,qBAAa,iBAAiB,CAAC,CAAC,SAAS,KAAK,GAAG,GAAG;IAClD,OAAO,CAAC,SAAS,CAAyB;IAC1C,OAAO,CAAC,MAAM,CAAsB;IACpC,OAAO,CAAC,SAAS,CAAiB;gBAEtB,SAAS,EAAE,KAAK,MAAM,EAAE,GAAG,KAAK,CAAC;IAI7C;;OAEG;IACH,UAAU,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI;IAKx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,GAAG,IAAI,GAAG,IAAI;IAK7C;;OAEG;IACH,aAAa,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI;IAKvC;;OAEG;IACG,KAAK,CAAC,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,CAAC,CAAC;CAG9C"}
@@ -1,18 +1,12 @@
1
1
  /**
2
- * @olane/o-test - Testing utilities for O-Network nodes
2
+ * @olane/o-test - Generic testing utilities for O-Network
3
3
  *
4
- * Provides comprehensive testing utilities, builders, and fixtures
5
- * to eliminate boilerplate in O-Network package tests.
4
+ * Provides generic testing utilities, assertions, mocks, and fixtures.
5
+ * Node-specific utilities (TestEnvironment, builders) have been moved to @olane/o-node/test/helpers
6
6
  */
7
- export { TestEnvironment } from './test-environment.js';
8
- export type { TestNodeConfig, LeaderNodeOptions, ToolWithLeaderResult, } from './test-environment.js';
9
- export { SimpleNodeBuilder, LeaderChildBuilder, ManagerWorkerBuilder, } from './builders/index.js';
10
- export type { LeaderConfig, ManagerWorkerResult } from './builders/index.js';
11
7
  export { waitFor, waitForAsync, sleep, ChunkCapture, assertSuccess, assertError, assertRunning, assertStopped, assertHasData, assertDefined, assertArrayLength, assertHasProperty, assertOneOf, assert, generateId, createMockUser, createMockTask, createMockSession, createMockRequest, createMockSuccessResponse, createMockErrorResponse, generateMockArray, } from './utils/index.js';
12
8
  export { INVALID_PARAMS, VALID_PARAMS, } from './utils/mock-factories.js';
13
9
  export { MOCK_USERS, MOCK_TASKS, MOCK_SESSIONS, MOCK_CONFIGS, MOCK_ADDRESSES, MOCK_ERRORS, MOCK_STREAM_CHUNKS, TEST_METHOD_SIMPLE, TEST_METHOD_COMPLEX, TEST_METHOD_VALIDATION, TEST_METHODS, getTestMethod, createTestMethod, } from './fixtures/index.js';
14
10
  export { INVALID_PARAMS as FIXTURE_INVALID_PARAMS } from './fixtures/mock-data.js';
15
11
  export { VALID_PARAMS as FIXTURE_VALID_PARAMS } from './fixtures/mock-data.js';
16
- export * from './example-tool.tool.js';
17
- export * from './methods/example.methods.js';
18
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,YAAY,EACV,cAAc,EACd,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAG7E,OAAO,EACL,OAAO,EACP,YAAY,EACZ,KAAK,EACL,YAAY,EAEZ,aAAa,EACb,WAAW,EACX,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,WAAW,EACX,MAAM,EAEN,UAAU,EACV,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EACjB,yBAAyB,EACzB,uBAAuB,EACvB,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,cAAc,EACd,YAAY,GACb,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EACL,UAAU,EACV,UAAU,EACV,aAAa,EACb,YAAY,EACZ,cAAc,EACd,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,EACtB,YAAY,EACZ,aAAa,EACb,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,cAAc,IAAI,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACnF,OAAO,EAAE,YAAY,IAAI,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAG/E,cAAc,wBAAwB,CAAC;AACvC,cAAc,8BAA8B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACL,OAAO,EACP,YAAY,EACZ,KAAK,EACL,YAAY,EAEZ,aAAa,EACb,WAAW,EACX,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,WAAW,EACX,MAAM,EAEN,UAAU,EACV,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EACjB,yBAAyB,EACzB,uBAAuB,EACvB,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,cAAc,EACd,YAAY,GACb,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EACL,UAAU,EACV,UAAU,EACV,aAAa,EACb,YAAY,EACZ,cAAc,EACd,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,EACtB,YAAY,EACZ,aAAa,EACb,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,cAAc,IAAI,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACnF,OAAO,EAAE,YAAY,IAAI,oBAAoB,EAAE,MAAM,yBAAyB,CAAC"}
package/dist/src/index.js CHANGED
@@ -1,13 +1,9 @@
1
1
  /**
2
- * @olane/o-test - Testing utilities for O-Network nodes
2
+ * @olane/o-test - Generic testing utilities for O-Network
3
3
  *
4
- * Provides comprehensive testing utilities, builders, and fixtures
5
- * to eliminate boilerplate in O-Network package tests.
4
+ * Provides generic testing utilities, assertions, mocks, and fixtures.
5
+ * Node-specific utilities (TestEnvironment, builders) have been moved to @olane/o-node/test/helpers
6
6
  */
7
- // Core test environment
8
- export { TestEnvironment } from './test-environment.js';
9
- // Test builders
10
- export { SimpleNodeBuilder, LeaderChildBuilder, ManagerWorkerBuilder, } from './builders/index.js';
11
7
  // Utilities
12
8
  export { waitFor, waitForAsync, sleep, ChunkCapture,
13
9
  // Assertions
@@ -20,6 +16,5 @@ export { MOCK_USERS, MOCK_TASKS, MOCK_SESSIONS, MOCK_CONFIGS, MOCK_ADDRESSES, MO
20
16
  // Re-export invalid/valid params from fixtures
21
17
  export { INVALID_PARAMS as FIXTURE_INVALID_PARAMS } from './fixtures/mock-data.js';
22
18
  export { VALID_PARAMS as FIXTURE_VALID_PARAMS } from './fixtures/mock-data.js';
23
- // Example tool (for reference/templates)
24
- export * from './example-tool.tool.js';
25
- export * from './methods/example.methods.js';
19
+ // Note: example-tool.tool.ts and example.methods.ts are available in the src directory
20
+ // as reference implementations, but are not exported to avoid dependencies on o-node/o-lane
@@ -4,7 +4,6 @@
4
4
  * Provides type-safe, expressive assertions for common test scenarios
5
5
  */
6
6
  import { oResponse } from '@olane/o-core';
7
- import type { oNode } from '@olane/o-node';
8
7
  /**
9
8
  * Assert that a tool response indicates success
10
9
  *
@@ -53,7 +52,7 @@ export declare function assertError(response: oResponse, expectedError?: string)
53
52
  * assertRunning(tool);
54
53
  * ```
55
54
  */
56
- export declare function assertRunning(node: oNode, message?: string): void;
55
+ export declare function assertRunning(node: any, message?: string): void;
57
56
  /**
58
57
  * Assert that a node is in stopped state
59
58
  *
@@ -67,7 +66,7 @@ export declare function assertRunning(node: oNode, message?: string): void;
67
66
  * assertStopped(tool);
68
67
  * ```
69
68
  */
70
- export declare function assertStopped(node: oNode, message?: string): void;
69
+ export declare function assertStopped(node: any, message?: string): void;
71
70
  /**
72
71
  * Assert that response has data
73
72
  *
@@ -1 +1 @@
1
- {"version":3,"file":"assertions.d.ts","sourceRoot":"","sources":["../../../src/utils/assertions.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAa,SAAS,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAE3C;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,SAAS,EACnB,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,QAAQ,IAAI,SAAS,GAAG;IAAE,MAAM,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,GACf,OAAO,CAAC,QAAQ,IAAI,SAAS,GAAG;IAAE,MAAM,EAAE;QAAE,IAAI,EAAE,GAAG,CAAA;KAAE,CAAA;CAAE,CAK3D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAC7B,KAAK,EAAE,CAAC,EACR,IAAI,GAAE,MAAgB,GACrB,OAAO,CAAC,KAAK,IAAI,WAAW,CAAC,CAAC,CAAC,CAIjC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,GAAG,EAAE,EACZ,cAAc,EAAE,MAAM,EACtB,OAAO,CAAC,EAAE,MAAM,GACf,IAAI,CAMN;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,WAAW,EACvE,GAAG,EAAE,CAAC,EACN,QAAQ,EAAE,CAAC,EACX,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,GAAG,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,CAMvC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAC3B,KAAK,EAAE,CAAC,EACR,cAAc,EAAE,CAAC,EAAE,EACnB,OAAO,CAAC,EAAE,MAAM,GACf,IAAI,CAMN;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,MAAM,CACpB,SAAS,EAAE,OAAO,EAClB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,SAAS,CAInB"}
@@ -1,8 +1,14 @@
1
1
  /**
2
- * Tests for TestEnvironment class
2
+ * Tests for generic testing utilities
3
3
  *
4
- * Validates the TestEnvironment utilities and serves as
5
- * documentation/examples for usage patterns.
4
+ * NOTE: TestEnvironment and builder tests have been moved to @olane/o-node/test
5
+ * since those utilities now reside in o-node/test/helpers to break circular dependencies.
6
+ *
7
+ * This file tests generic utilities that remain in o-test:
8
+ * - waitFor, ChunkCapture
9
+ * - Assertions (assertSuccess, assertError, etc.)
10
+ * - Mock factories
11
+ * - Fixtures
6
12
  */
7
13
  import 'dotenv/config';
8
14
  //# sourceMappingURL=test-environment.spec.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"test-environment.spec.d.ts","sourceRoot":"","sources":["../../test/test-environment.spec.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,eAAe,CAAC"}
1
+ {"version":3,"file":"test-environment.spec.d.ts","sourceRoot":"","sources":["../../test/test-environment.spec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,eAAe,CAAC"}
@@ -1,153 +1,25 @@
1
1
  /**
2
- * Tests for TestEnvironment class
2
+ * Tests for generic testing utilities
3
3
  *
4
- * Validates the TestEnvironment utilities and serves as
5
- * documentation/examples for usage patterns.
4
+ * NOTE: TestEnvironment and builder tests have been moved to @olane/o-node/test
5
+ * since those utilities now reside in o-node/test/helpers to break circular dependencies.
6
+ *
7
+ * This file tests generic utilities that remain in o-test:
8
+ * - waitFor, ChunkCapture
9
+ * - Assertions (assertSuccess, assertError, etc.)
10
+ * - Mock factories
11
+ * - Fixtures
6
12
  */
7
13
  import 'dotenv/config';
8
14
  import { expect } from 'chai';
9
15
  import { NodeState } from '@olane/o-core';
10
- import { oNodeAddress } from '@olane/o-node';
11
- import { TestEnvironment, SimpleNodeBuilder, waitFor, ChunkCapture, assertSuccess, assertError, assertRunning, assertStopped, assertHasData, createMockUser, MOCK_USERS, } from '../src/index.js';
12
- // Mock node class for testing
16
+ import { waitFor, ChunkCapture, assertSuccess, assertError, assertRunning, assertStopped, assertHasData, createMockUser, MOCK_USERS, } from '../src/index.js';
17
+ // Mock node class for testing assertions
13
18
  class MockNode {
14
- constructor(config = {}) {
15
- this.state = NodeState.STOPPED;
16
- this.config = config;
17
- this.address = config.address || new oNodeAddress('o://mock-node');
18
- }
19
- async start() {
20
- this.state = NodeState.RUNNING;
21
- }
22
- async stop() {
19
+ constructor() {
23
20
  this.state = NodeState.STOPPED;
24
21
  }
25
22
  }
26
- describe('TestEnvironment', () => {
27
- let env;
28
- beforeEach(() => {
29
- env = new TestEnvironment();
30
- });
31
- afterEach(async () => {
32
- await env.cleanup();
33
- });
34
- describe('Lifecycle Management', () => {
35
- it('should track nodes for cleanup', async () => {
36
- const node = new MockNode();
37
- env.track(node);
38
- expect(env.getNodeCount()).to.equal(1);
39
- expect(env.getNodes()).to.have.lengthOf(1);
40
- expect(env.getNodes()[0]).to.equal(node);
41
- });
42
- it('should create and track simple node', async () => {
43
- const node = await env.createNode(MockNode, {}, false);
44
- expect(env.getNodeCount()).to.equal(1);
45
- expect(node.state).to.equal(NodeState.STOPPED);
46
- });
47
- it('should auto-start nodes by default', async () => {
48
- const node = await env.createNode(MockNode);
49
- expect(node.state).to.equal(NodeState.RUNNING);
50
- });
51
- it('should stop all nodes in cleanup', async () => {
52
- const node1 = await env.createNode(MockNode);
53
- const node2 = await env.createNode(MockNode);
54
- expect(node1.state).to.equal(NodeState.RUNNING);
55
- expect(node2.state).to.equal(NodeState.RUNNING);
56
- await env.cleanup();
57
- expect(node1.state).to.equal(NodeState.STOPPED);
58
- expect(node2.state).to.equal(NodeState.STOPPED);
59
- expect(env.allNodesStopped()).to.be.true;
60
- });
61
- it('should execute cleanup callbacks', async () => {
62
- let callbackExecuted = false;
63
- env.onCleanup(async () => {
64
- callbackExecuted = true;
65
- });
66
- await env.cleanup();
67
- expect(callbackExecuted).to.be.true;
68
- });
69
- it('should clear tracking after cleanup', async () => {
70
- const node = await env.createNode(MockNode);
71
- expect(env.getNodeCount()).to.equal(1);
72
- await env.cleanup();
73
- expect(env.getNodeCount()).to.equal(0);
74
- });
75
- });
76
- describe('Node Creation', () => {
77
- it('should pass config to node constructor', async () => {
78
- const testConfig = {
79
- apiKey: 'test-key',
80
- timeout: 5000,
81
- };
82
- const node = await env.createNode(MockNode, testConfig);
83
- expect(node.config.apiKey).to.equal('test-key');
84
- expect(node.config.timeout).to.equal(5000);
85
- });
86
- it('should set parent and leader to null for simple nodes', async () => {
87
- const node = await env.createNode(MockNode);
88
- expect(node.config.parent).to.be.null;
89
- expect(node.config.leader).to.be.null;
90
- });
91
- });
92
- describe('waitFor Utility', () => {
93
- it('should wait for condition to be true', async () => {
94
- let counter = 0;
95
- setTimeout(() => { counter = 5; }, 100);
96
- await env.waitFor(() => counter === 5, 1000);
97
- expect(counter).to.equal(5);
98
- });
99
- it('should timeout if condition not met', async () => {
100
- let error = null;
101
- try {
102
- await env.waitFor(() => false, 100);
103
- }
104
- catch (e) {
105
- error = e;
106
- }
107
- expect(error).to.exist;
108
- expect(error?.message).to.include('Timeout');
109
- });
110
- it('should check condition immediately', async () => {
111
- const startTime = Date.now();
112
- await env.waitFor(() => true, 5000);
113
- const duration = Date.now() - startTime;
114
- // Should return almost immediately
115
- expect(duration).to.be.lessThan(100);
116
- });
117
- });
118
- });
119
- describe('Test Builders', () => {
120
- let env;
121
- beforeEach(() => {
122
- env = new TestEnvironment();
123
- });
124
- afterEach(async () => {
125
- await env.cleanup();
126
- });
127
- describe('SimpleNodeBuilder', () => {
128
- it('should build node with fluent API', async () => {
129
- const node = await new SimpleNodeBuilder(MockNode)
130
- .withAddress('o://test-builder')
131
- .withDescription('Test node')
132
- .build(env);
133
- expect(node).to.exist;
134
- expect(node.state).to.equal(NodeState.RUNNING);
135
- expect(env.getNodeCount()).to.equal(1);
136
- });
137
- it('should respect autoStart flag', async () => {
138
- const node = await new SimpleNodeBuilder(MockNode)
139
- .withAutoStart(false)
140
- .build(env);
141
- expect(node.state).to.equal(NodeState.STOPPED);
142
- });
143
- it('should pass config through', async () => {
144
- const node = await new SimpleNodeBuilder(MockNode)
145
- .withConfig({ custom: 'value' })
146
- .build(env);
147
- expect(node.config.custom).to.equal('value');
148
- });
149
- });
150
- });
151
23
  describe('Utilities', () => {
152
24
  describe('waitFor', () => {
153
25
  it('should wait for condition', async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@olane/o-test",
3
- "version": "0.7.12",
3
+ "version": "0.7.13-alpha.1",
4
4
  "type": "module",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",
@@ -68,20 +68,11 @@
68
68
  "tsx": "^4.20.3",
69
69
  "typescript": "5.4.5"
70
70
  },
71
- "peerDependencies": {
72
- "@olane/o-config": "^0.7.12",
73
- "@olane/o-core": "^0.7.12",
74
- "@olane/o-lane": "^0.7.12",
75
- "@olane/o-leader": "^0.7.12",
76
- "@olane/o-node": "^0.7.12",
77
- "@olane/o-protocol": "^0.7.12",
78
- "@olane/o-tool": "^0.7.12",
79
- "chai": "^5.1.2"
80
- },
81
71
  "dependencies": {
72
+ "@olane/o-core": "0.7.13-alpha.1",
82
73
  "chalk": "^5.4.1",
83
74
  "debug": "^4.4.1",
84
75
  "dotenv": "^16.5.0"
85
76
  },
86
- "gitHead": "580d8c51fe0a12695ba1d77f077029200f0c8af4"
77
+ "gitHead": "7abba2239f85eb07a87401528b6df96e72449fe0"
87
78
  }
@@ -1 +0,0 @@
1
- //# sourceMappingURL=example.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"example.spec.d.ts","sourceRoot":"","sources":["../../test/example.spec.ts"],"names":[],"mappings":""}
@@ -1,240 +0,0 @@
1
- "use strict";
2
- // import { expect } from 'chai';
3
- // import { ExampleTool } from '../src/example-tool.tool.js';
4
- // import { oRequest } from '@olane/o-core';
5
- // import { NodeState } from '@olane/o-node';
6
- // import { mockData } from './fixtures/mock-data.js';
7
- // /**
8
- // * Example tests for the ExampleTool
9
- // *
10
- // * These tests demonstrate:
11
- // * - Tool initialization and lifecycle
12
- // * - Method testing
13
- // * - Success and error cases
14
- // * - Using test fixtures
15
- // *
16
- // * Run with: npm test
17
- // */
18
- // describe('ExampleTool', () => {
19
- // let tool: ExampleTool;
20
- // beforeEach(() => {
21
- // // Initialize a new tool instance before each test
22
- // tool = new ExampleTool({
23
- // debugMode: false,
24
- // timeout: 5000,
25
- // });
26
- // });
27
- // afterEach(async () => {
28
- // // Clean up after each test
29
- // if (tool && tool.state === NodeState.RUNNING) {
30
- // await tool.stop();
31
- // }
32
- // });
33
- // describe('Initialization', () => {
34
- // it('should initialize the tool successfully', async () => {
35
- // await tool.start();
36
- // expect(tool.state).to.equal(NodeState.RUNNING);
37
- // });
38
- // it('should initialize with custom configuration', () => {
39
- // const customTool = new ExampleTool({
40
- // debugMode: true,
41
- // timeout: 10000,
42
- // customOption: 'test-value',
43
- // });
44
- // expect(customTool).to.exist;
45
- // });
46
- // it('should stop the tool successfully', async () => {
47
- // await tool.start();
48
- // expect(tool.state).to.equal(NodeState.RUNNING);
49
- // await tool.stop();
50
- // expect(tool.state).to.equal(NodeState.STOPPED);
51
- // });
52
- // });
53
- // describe('example_method', () => {
54
- // beforeEach(async () => {
55
- // await tool.start();
56
- // });
57
- // it('should process a message successfully', async () => {
58
- // const request = new oRequest({
59
- // method: 'example_method',
60
- // params: { message: 'Hello, oLane!' },
61
- // });
62
- // const result = await tool.callMyTool(request);
63
- // expect(result.success).to.be.true;
64
- // expect(result.result).to.include('Hello, oLane!');
65
- // expect(result.result).to.include('Processed:');
66
- // expect(result.timestamp).to.be.a('number');
67
- // });
68
- // it('should process a message with metadata', async () => {
69
- // const request = new oRequest({
70
- // method: 'example_method',
71
- // params: {
72
- // message: 'Test message',
73
- // metadata: { userId: '123', source: 'test' },
74
- // },
75
- // });
76
- // const result = await tool.callMyTool(request);
77
- // expect(result.success).to.be.true;
78
- // expect(result.result).to.include('Test message');
79
- // });
80
- // it('should return error when message parameter is missing', async () => {
81
- // const request = new oRequest({
82
- // method: 'example_method',
83
- // params: {},
84
- // });
85
- // const result = await tool.callMyTool(request);
86
- // expect(result.success).to.be.false;
87
- // expect(result.error).to.include('required');
88
- // });
89
- // it('should use mock data from fixtures', async () => {
90
- // const request = new oRequest({
91
- // method: 'example_method',
92
- // params: { message: mockData.sampleMessage },
93
- // });
94
- // const result = await tool.callMyTool(request);
95
- // expect(result.success).to.be.true;
96
- // expect(result.result).to.include(mockData.sampleMessage);
97
- // });
98
- // });
99
- // describe('process_data', () => {
100
- // beforeEach(async () => {
101
- // await tool.start();
102
- // });
103
- // it('should process data in JSON format', async () => {
104
- // const testData = { name: 'John', age: 30 };
105
- // const request = new oRequest({
106
- // method: 'process_data',
107
- // params: {
108
- // data: testData,
109
- // options: { format: 'json' },
110
- // },
111
- // });
112
- // const result = await tool.callMyTool(request);
113
- // expect(result.success).to.be.true;
114
- // expect(result.data).to.deep.equal(testData);
115
- // });
116
- // it('should process data in text format', async () => {
117
- // const testData = { name: 'John', age: 30 };
118
- // const request = new oRequest({
119
- // method: 'process_data',
120
- // params: {
121
- // data: testData,
122
- // options: { format: 'text' },
123
- // },
124
- // });
125
- // const result = await tool.callMyTool(request);
126
- // expect(result.success).to.be.true;
127
- // expect(result.data).to.be.a('string');
128
- // expect(result.data).to.include('John');
129
- // });
130
- // it('should process data in HTML format', async () => {
131
- // const testData = { name: 'John', age: 30 };
132
- // const request = new oRequest({
133
- // method: 'process_data',
134
- // params: {
135
- // data: testData,
136
- // options: { format: 'html' },
137
- // },
138
- // });
139
- // const result = await tool.callMyTool(request);
140
- // expect(result.success).to.be.true;
141
- // expect(result.data).to.include('<pre>');
142
- // expect(result.data).to.include('John');
143
- // });
144
- // it('should return error when data parameter is missing', async () => {
145
- // const request = new oRequest({
146
- // method: 'process_data',
147
- // params: {},
148
- // });
149
- // const result = await tool.callMyTool(request);
150
- // expect(result.success).to.be.false;
151
- // expect(result.error).to.include('required');
152
- // });
153
- // it('should return error for unsupported format', async () => {
154
- // const request = new oRequest({
155
- // method: 'process_data',
156
- // params: {
157
- // data: { test: 'data' },
158
- // options: { format: 'invalid' as any },
159
- // },
160
- // });
161
- // const result = await tool.callMyTool(request);
162
- // expect(result.success).to.be.false;
163
- // expect(result.error).to.include('Unsupported format');
164
- // });
165
- // it('should validate data when requested', async () => {
166
- // const invalidData = { value: 'test' }; // No name or id field
167
- // const request = new oRequest({
168
- // method: 'process_data',
169
- // params: {
170
- // data: invalidData,
171
- // options: { validate: true },
172
- // },
173
- // });
174
- // const result = await tool.callMyTool(request);
175
- // expect(result.success).to.be.false;
176
- // expect(result.error).to.include('Validation failed');
177
- // expect(result.validationErrors).to.be.an('array');
178
- // });
179
- // it('should pass validation with valid data', async () => {
180
- // const validData = { name: 'John', age: 30 };
181
- // const request = new oRequest({
182
- // method: 'process_data',
183
- // params: {
184
- // data: validData,
185
- // options: { validate: true },
186
- // },
187
- // });
188
- // const result = await tool.callMyTool(request);
189
- // expect(result.success).to.be.true;
190
- // expect(result.data).to.deep.equal(validData);
191
- // });
192
- // });
193
- // describe('get_status', () => {
194
- // beforeEach(async () => {
195
- // await tool.start();
196
- // });
197
- // it('should return tool status', async () => {
198
- // const request = new oRequest({
199
- // method: 'get_status',
200
- // params: {},
201
- // });
202
- // const result = await tool.callMyTool(request);
203
- // expect(result.success).to.be.true;
204
- // expect(result.status).to.exist;
205
- // expect(result.status.state).to.equal(NodeState.RUNNING);
206
- // expect(result.status.address).to.include('o://example');
207
- // expect(result.status.methods).to.be.an('array');
208
- // expect(result.status.methods).to.include('example_method');
209
- // expect(result.status.methods).to.include('process_data');
210
- // expect(result.status.methods).to.include('get_status');
211
- // });
212
- // it('should include configuration in status', async () => {
213
- // const request = new oRequest({
214
- // method: 'get_status',
215
- // params: {},
216
- // });
217
- // const result = await tool.callMyTool(request);
218
- // expect(result.success).to.be.true;
219
- // expect(result.status.debugMode).to.be.a('boolean');
220
- // expect(result.status.timeout).to.be.a('number');
221
- // });
222
- // });
223
- // describe('Error Handling', () => {
224
- // beforeEach(async () => {
225
- // await tool.start();
226
- // });
227
- // it('should handle invalid method gracefully', async () => {
228
- // const request = new oRequest({
229
- // method: 'invalid_method',
230
- // params: {},
231
- // });
232
- // try {
233
- // await tool.callMyTool(request);
234
- // // Should throw or return error
235
- // } catch (error) {
236
- // expect(error).to.exist;
237
- // }
238
- // });
239
- // });
240
- // });
@@ -1 +0,0 @@
1
- //# sourceMappingURL=mock-data.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mock-data.d.ts","sourceRoot":"","sources":["../../../test/fixtures/mock-data.ts"],"names":[],"mappings":""}
@@ -1,90 +0,0 @@
1
- "use strict";
2
- // /**
3
- // * Mock data for testing
4
- // *
5
- // * This file contains sample data used in tests.
6
- // * Organize your test fixtures here to keep tests clean and maintainable.
7
- // */
8
- // export const mockData = {
9
- // /**
10
- // * Sample message for testing example_method
11
- // */
12
- // sampleMessage: 'This is a test message from mock data',
13
- // /**
14
- // * Sample data object for testing process_data
15
- // */
16
- // sampleData: {
17
- // id: 'test-123',
18
- // name: 'Test User',
19
- // email: 'test@example.com',
20
- // metadata: {
21
- // created: '2025-01-01T00:00:00Z',
22
- // source: 'test-fixture',
23
- // },
24
- // },
25
- // /**
26
- // * Sample data for validation testing
27
- // */
28
- // validData: {
29
- // name: 'Valid User',
30
- // id: 'valid-123',
31
- // email: 'valid@example.com',
32
- // },
33
- // /**
34
- // * Invalid data for testing validation errors
35
- // */
36
- // invalidData: {
37
- // value: 'missing required fields',
38
- // // Missing name and id
39
- // },
40
- // /**
41
- // * Sample metadata for testing
42
- // */
43
- // sampleMetadata: {
44
- // userId: 'user-123',
45
- // sessionId: 'session-456',
46
- // timestamp: 1704067200000,
47
- // source: 'test',
48
- // },
49
- // /**
50
- // * Sample complex nested data
51
- // */
52
- // complexData: {
53
- // users: [
54
- // { id: 1, name: 'Alice', role: 'admin' },
55
- // { id: 2, name: 'Bob', role: 'user' },
56
- // { id: 3, name: 'Charlie', role: 'user' },
57
- // ],
58
- // settings: {
59
- // theme: 'dark',
60
- // notifications: true,
61
- // language: 'en',
62
- // },
63
- // stats: {
64
- // totalUsers: 3,
65
- // activeUsers: 2,
66
- // lastUpdate: '2025-01-01T12:00:00Z',
67
- // },
68
- // },
69
- // };
70
- // /**
71
- // * Helper function to create mock requests
72
- // */
73
- // export function createMockRequest(method: string, params: any = {}) {
74
- // return {
75
- // method,
76
- // params,
77
- // timestamp: Date.now(),
78
- // };
79
- // }
80
- // /**
81
- // * Helper function to create mock configuration
82
- // */
83
- // export function createMockConfig(overrides: any = {}) {
84
- // return {
85
- // debugMode: false,
86
- // timeout: 5000,
87
- // customOption: 'test-value',
88
- // ...overrides,
89
- // };
90
- // }