refactor: move brother_node development artifact to dev/test-nodes subdirectory
Development Artifact Cleanup: ✅ BROTHER_NODE REORGANIZATION: Moved development test node to appropriate location - dev/test-nodes/brother_node/: Moved from root directory for better organization - Contains development configuration, test logs, and test chain data - No impact on production systems - purely development/testing artifact ✅ DEVELOPMENT ARTIFACTS IDENTIFIED: - Chain ID: aitbc-brother-chain (test/development chain) - Ports: 8010 (P2P) and 8011 (RPC) - different from production - Environment: .env file with test configuration - Logs: rpc.log and node.log from development testing session (March 15, 2026) ✅ ROOT DIRECTORY CLEANUP: Removed development clutter from production directory - brother_node/ moved to dev/test-nodes/brother_node/ - Root directory now contains only production-ready components - Development artifacts properly organized in dev/ subdirectory DIRECTORY STRUCTURE IMPROVEMENT: 📁 dev/test-nodes/: Development and testing node configurations 🏗️ Root Directory: Clean production structure with only essential components 🧪 Development Isolation: Test environments separated from production BENEFITS: ✅ Clean Production Directory: No development artifacts in root ✅ Better Organization: Development nodes grouped in dev/ subdirectory ✅ Clear Separation: Production vs development environments clearly distinguished ✅ Maintainability: Easier to identify and manage development components RESULT: Successfully moved brother_node development artifact to dev/test-nodes/ subdirectory, cleaning up the root directory while preserving development testing environment for future use.
This commit is contained in:
146
dev/env/node_modules/@streamparser/json/test/callbacks.ts
generated
vendored
Executable file
146
dev/env/node_modules/@streamparser/json/test/callbacks.ts
generated
vendored
Executable file
@@ -0,0 +1,146 @@
|
||||
import JSONParser from "../src/jsonparser.js";
|
||||
import Tokenizer from "../src/tokenizer.js";
|
||||
import TokenParser from "../src/tokenparser.js";
|
||||
import TokenType from "../src/utils/types/tokenType.js";
|
||||
|
||||
describe("callback", () => {
|
||||
test("should error on missing onToken callback", () => {
|
||||
const p = new Tokenizer();
|
||||
|
||||
try {
|
||||
p.write('"test"');
|
||||
fail("Expected to fail(");
|
||||
} catch {
|
||||
// Expected error
|
||||
}
|
||||
});
|
||||
|
||||
test("should error if missing onError callback", () => {
|
||||
const p = new TokenParser();
|
||||
p.end();
|
||||
|
||||
try {
|
||||
p.write({ token: TokenType.TRUE, value: true });
|
||||
fail("Expected to fail(");
|
||||
} catch {
|
||||
// Expected error
|
||||
}
|
||||
});
|
||||
|
||||
test("should error on missing onValue callback", () => {
|
||||
const p = new JSONParser();
|
||||
|
||||
try {
|
||||
p.write('"test"');
|
||||
fail("Expected to fail(");
|
||||
} catch {
|
||||
// Expected error
|
||||
}
|
||||
});
|
||||
|
||||
test("should emit onValue callback when the onToken callback is also set", () => {
|
||||
const p = new JSONParser();
|
||||
|
||||
const onValueCb = jest.fn(() => {
|
||||
/* Do nothing */
|
||||
});
|
||||
p.onValue = onValueCb;
|
||||
p.onToken = () => {
|
||||
/* Do nothing */
|
||||
};
|
||||
|
||||
p.write('"test"');
|
||||
expect(onValueCb.mock.calls).toHaveLength(1);
|
||||
expect(
|
||||
(onValueCb.mock.calls[0] as unknown as [{ value: string }])[0].value,
|
||||
).toBe("test");
|
||||
});
|
||||
|
||||
test("should handle invalid input using the onError callback if set", () => {
|
||||
const p = new JSONParser();
|
||||
p.onValue = () => {
|
||||
/* Do nothing */
|
||||
};
|
||||
p.onError = (err) =>
|
||||
expect(err.message).toEqual(
|
||||
"Unexpected type. The `write` function only accepts Arrays, TypedArrays and Strings.",
|
||||
);
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
p.write(745674 as any);
|
||||
});
|
||||
|
||||
test("should handle parsing errors using the onError callback if set", () => {
|
||||
const p = new JSONParser();
|
||||
p.onValue = () => {
|
||||
/* Do nothing */
|
||||
};
|
||||
p.onError = (err) =>
|
||||
expect(err.message).toEqual(
|
||||
'Unexpected "t" at position "2" in state ENDED',
|
||||
);
|
||||
|
||||
p.write('""test""');
|
||||
});
|
||||
|
||||
test("should handle errors on callbacks using the onError callback if set", () => {
|
||||
const p = new JSONParser();
|
||||
p.onValue = () => {
|
||||
throw new Error("Unexpected error in onValue callback");
|
||||
};
|
||||
p.onError = (err) =>
|
||||
expect(err.message).toEqual("Unexpected error in onValue callback");
|
||||
|
||||
p.write('"test"');
|
||||
});
|
||||
|
||||
test("should handle errors on callbacks using the onError callback if set (tokenizer)", () => {
|
||||
const p = new Tokenizer();
|
||||
p.onToken = () => {
|
||||
throw new Error("Unexpected error in onValue callback");
|
||||
};
|
||||
p.onError = (err) =>
|
||||
expect(err.message).toEqual("Unexpected error in onValue callback");
|
||||
|
||||
p.write('"test"');
|
||||
});
|
||||
|
||||
test("should handle processing end using the onEnd callback if set", (done) => {
|
||||
const p = new JSONParser();
|
||||
p.onValue = () => {
|
||||
/* Do nothing */
|
||||
};
|
||||
p.onEnd = () => done();
|
||||
|
||||
p.write('"test"');
|
||||
});
|
||||
|
||||
test("should use default onEnd callback if none set up", () => {
|
||||
const p = new Tokenizer();
|
||||
p.onToken = () => {
|
||||
/* Do nothing */
|
||||
};
|
||||
|
||||
p.write("1");
|
||||
p.end();
|
||||
|
||||
expect(p.isEnded).toBeTruthy();
|
||||
});
|
||||
|
||||
test("should not fail if ending while the underlying tokenizer is already ended", () => {
|
||||
const separator = "\n";
|
||||
|
||||
const p = new JSONParser({ separator });
|
||||
p.onValue = () => {
|
||||
/* Do nothing */
|
||||
};
|
||||
p.onEnd = () => {
|
||||
/* Do nothing */
|
||||
};
|
||||
|
||||
p.write("{}");
|
||||
p.end();
|
||||
|
||||
expect(p.isEnded).toBeTruthy();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user