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.
120 lines
3.3 KiB
TypeScript
Executable File
120 lines
3.3 KiB
TypeScript
Executable File
import {
|
|
runJSONParserTest,
|
|
runTokenParserTest,
|
|
TestData,
|
|
} from "./utils/testRunner.js";
|
|
import JSONParser from "../src/jsonparser.js";
|
|
import TokenParser from "../src/tokenparser.js";
|
|
import TokenType from "@streamparser/json/utils/types/tokenType.js";
|
|
|
|
describe("separator", () => {
|
|
const testData: TestData[] = [
|
|
{ value: "true", expected: [true] },
|
|
{ value: "false", expected: [false] },
|
|
{ value: "null", expected: [null] },
|
|
{ value: '"string"', expected: ["string"] },
|
|
{ value: "[1,2,3]", expected: [1, 2, 3, [1, 2, 3]] },
|
|
{
|
|
value: '{ "a": 0, "b": 1, "c": -1 }',
|
|
expected: [0, 1, -1, { a: 0, b: 1, c: -1 }],
|
|
},
|
|
];
|
|
|
|
const expected = testData
|
|
.map(({ expected }) => expected)
|
|
.reduce((acc, val) => [...acc, ...val], []);
|
|
|
|
const separators = ["", "\n", "\t\n", "abc", "SEPARATOR"];
|
|
separators.forEach((separator) => {
|
|
test(`separator: "${separator}"`, async () => {
|
|
let i = 0;
|
|
|
|
await runJSONParserTest(
|
|
new JSONParser({ separator }),
|
|
testData.flatMap(({ value }) => [value, separator]),
|
|
({ value }) => {
|
|
expect(value).toEqual(expected[i]);
|
|
i += 1;
|
|
},
|
|
);
|
|
});
|
|
});
|
|
|
|
test("support multiple whitespace separators", async () => {
|
|
let i = 0;
|
|
const value = "1 2\t3\n4\n\r5 \n6\n\n7\n\r\n\r8 \t\n\n\r9";
|
|
const expected = [1, 2, 3, 4, 5, 6, 7, 8, 9];
|
|
const separator = "";
|
|
|
|
await runJSONParserTest(
|
|
new JSONParser({ separator }),
|
|
value,
|
|
({ value }) => {
|
|
expect(value).toEqual(expected[i]);
|
|
i += 1;
|
|
},
|
|
);
|
|
});
|
|
|
|
test(`separator: fail on invalid value`, async () => {
|
|
try {
|
|
await runJSONParserTest(new JSONParser({ separator: "abc" }), ["abe"]);
|
|
} catch (err: unknown) {
|
|
expect(err).toBeInstanceOf(Error);
|
|
expect((err as Error).message).toEqual(
|
|
'Unexpected "e" at position "2" in state SEPARATOR',
|
|
);
|
|
}
|
|
});
|
|
|
|
test(`fail on invalid token type`, async () => {
|
|
try {
|
|
await runTokenParserTest(new TokenParser({ separator: "\n" }), [
|
|
{ token: TokenType.TRUE, value: true },
|
|
{ token: TokenType.TRUE, value: true },
|
|
]);
|
|
fail("Error expected on invalid selector");
|
|
} catch (err: unknown) {
|
|
expect(err).toBeInstanceOf(Error);
|
|
expect((err as Error).message).toEqual(
|
|
"Unexpected TRUE (true) in state SEPARATOR",
|
|
);
|
|
}
|
|
});
|
|
|
|
test("fail on invalid value passed to TokenParser", async () => {
|
|
try {
|
|
await runTokenParserTest(new TokenParser({ separator: "\n" }), [
|
|
{ token: TokenType.TRUE, value: true },
|
|
{ token: TokenType.SEPARATOR, value: "\r\n" },
|
|
]);
|
|
fail("Error expected on invalid selector");
|
|
} catch (err: unknown) {
|
|
expect(err).toBeInstanceOf(Error);
|
|
expect((err as Error).message).toEqual(
|
|
'Unexpected SEPARATOR ("\\r\\n") in state SEPARATOR',
|
|
);
|
|
}
|
|
});
|
|
|
|
test("not fail when whitespaces match separator", async () => {
|
|
let i = 0;
|
|
const value = `{
|
|
"a": 0,
|
|
"b": 1,
|
|
"c": -1
|
|
}`;
|
|
const expected = [0, 1, -1, { a: 0, b: 1, c: -1 }];
|
|
const separator = "\n";
|
|
|
|
await runJSONParserTest(
|
|
new JSONParser({ separator }),
|
|
value,
|
|
({ value }) => {
|
|
expect(value).toEqual(expected[i]);
|
|
i += 1;
|
|
},
|
|
);
|
|
});
|
|
});
|