Skip to content

Including explanations and comments on the structure test suites to U… #177

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 66 additions & 61 deletions tests/jsonColumnView.test.ts
Original file line number Diff line number Diff line change
@@ -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" },
Expand All @@ -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",
}
`);
});
});