From 1630bc8b9cf40ab724406d081cae1c9cf92c646b Mon Sep 17 00:00:00 2001 From: Gordian <68512769+Gordiancyber@users.noreply.github.com> Date: Sun, 29 Oct 2023 06:20:04 +0100 Subject: [PATCH] Including explanations and comments on the structure test suites to Update jsonColumnView.test.ts Adding comments to Include explanations and comments on the structure test suites --- tests/jsonColumnView.test.ts | 127 ++++++++++++++++++----------------- 1 file changed, 66 insertions(+), 61 deletions(-) diff --git a/tests/jsonColumnView.test.ts b/tests/jsonColumnView.test.ts index 3d6d42a2..c7642cf0 100644 --- a/tests/jsonColumnView.test.ts +++ b/tests/jsonColumnView.test.ts @@ -1,7 +1,11 @@ +// Import the function for generating a tree structure from JSON import { generateColumnViewNode } from "../app/utilities/jsonColumnView"; +// Test suite for the generateColumnViewNode function describe("generateColumnViewNode", () => { + // Test case to ensure the function creates the correct tree structure for the passed JSON test("it creates the correct tree structure for the passed in JSON", () => { + // Sample JSON data to be converted into a tree structure const json = { string: "foo bar", data: { foo: "bar" }, @@ -12,67 +16,68 @@ describe("generateColumnViewNode", () => { ], }; + // Verify that the generated tree structure matches the expected snapshot expect(generateColumnViewNode(json)).toMatchInlineSnapshot(` -Object { - "children": Array [ - Object { - "children": Array [], - "icon": [Function], - "id": "$.string", - "name": "string", - "subtitle": "foo bar", - "title": "string", - }, - Object { - "children": Array [ - Object { - "children": Array [], - "icon": [Function], - "id": "$.data.foo", - "name": "foo", - "subtitle": "bar", - "title": "foo", - }, - ], - "icon": [Function], - "id": "$.data", - "name": "data", - "subtitle": "1 field", - "title": "data", - }, - Object { - "children": Array [ - Object { - "children": Array [ - Object { - "children": Array [], - "icon": [Function], - "id": "$.array.0.string", - "name": "string", - "subtitle": "foo bar", - "title": "string", - }, - ], - "icon": [Function], - "id": "$.array.0", - "longTitle": "Index 0", - "name": "0", - "subtitle": "1 field", - "title": "0", - }, - ], - "icon": [Function], - "id": "$.array", - "name": "array", - "subtitle": "1 item", - "title": "array", - }, - ], - "icon": [Function], - "id": "$", - "name": "root", - "title": "root", -} -`); + Object { + "children": Array [ + Object { + "children": Array [], + "icon": [Function], + "id": "$.string", + "name": "string", + "subtitle": "foo bar", + "title": "string", + }, + Object { + "children": Array [ + Object { + "children": Array [], + "icon": [Function], + "id": "$.data.foo", + "name": "foo", + "subtitle": "bar", + "title": "foo", + }, + ], + "icon": [Function], + "id": "$.data", + "name": "data", + "subtitle": "1 field", + "title": "data", + }, + Object { + "children": Array [ + Object { + "children": Array [ + Object { + "children": Array [], + "icon": [Function], + "id": "$.array.0.string", + "name": "string", + "subtitle": "foo bar", + "title": "string", + }, + ], + "icon": [Function], + "id": "$.array.0", + "longTitle": "Index 0", + "name": "0", + "subtitle": "1 field", + "title": "0", + }, + ], + "icon": [Function], + "id": "$.array", + "name": "array", + "subtitle": "1 item", + "title": "array", + }, + ], + "icon": [Function], + "id": "$", + "name": "root", + "title": "root", + } + `); }); });