MCPcopy
hub / github.com/loggerhead/json4u / expectFindNodeAtOffset

Function expectFindNodeAtOffset

__tests__/parseAndFormat.test.ts:45–61  ·  view source on GitHub ↗
(tree: Tree, aa: TestData[])

Source from the content-addressed store, hash-verified

43}
44
45function expectFindNodeAtOffset(tree: Tree, aa: TestData[]) {
46 for (const { id, offset, length, boundOffset, boundLength } of aa) {
47 {
48 const r = tree.findNodeAtOffset(boundOffset);
49 const parentId = getParentId(id);
50 expect(r?.node?.id).toEqual(parentId);
51 }
52 {
53 const r = tree.findNodeAtOffset(boundOffset + boundLength);
54 expect(r?.node?.id).toEqual(id);
55 }
56 {
57 const r = tree.findNodeAtOffset(offset + 1);
58 expect(r?.node?.id).toEqual(id);
59 }
60 }
61}
62
63describe("check offset and boundOffset of parseAndFormat", () => {
64 test("literal value", async () => {

Callers 1

doExpectFunction · 0.85

Calls 2

getParentIdFunction · 0.90
findNodeAtOffsetMethod · 0.80

Tested by

no test coverage detected