Skip to content
Open
Show file tree
Hide file tree
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
7 changes: 3 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
language: node_js
node_js:
- "0.8"
# - "4"
# - "6"
# - "8"
- "6"
- "8"
# - "9"
- "10"

18 changes: 18 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "tests",
"program": "${workspaceFolder}/node_modules/.bin/jest",
"args": ["--runInBand", "--no-coverage"],
"env": {
"TZ": "UTC"
}
}
]
}
22 changes: 14 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,30 @@
"description": "converts a JS object into a nice and readable tree structure for the console",
"license": "MIT",
"scripts": {
"test": "./node_modules/vows/bin/vows --spec"
"test": "TZ=UTC ./node_modules/.bin/jest"
},
"main": "./treeify",
"repository": {
"type": "git",
"url": "https://github.com/notatestuser/treeify.git"
},
"keywords": [
"object", "tree", "print", "console", "pretty"
"object",
"tree",
"print",
"console",
"pretty"
],
"devDependencies": {
"vows": "git://github.com/Filirom1/vows.git#expect"
"jest": "^23.3.0"
},
"licenses": [{
"type": "MIT",
"url": "http://lp.mit-license.org/"
}],
"licenses": [
{
"type": "MIT",
"url": "http://lp.mit-license.org/"
}
],
"engines": {
"node": ">=0.6"
"node": ">= 6"
}
}
253 changes: 253 additions & 0 deletions test/__snapshots__/tree-test.spec.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,253 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`tree-test A tree created from a multi-level object when returned as a whole tree with values hidden produces correct output 1`] = `
"
├─ oranges
│ └─ mandarin
│ ├─ clementine
│ └─ tangerine
└─ apples
├─ gala
└─ pink lady
"
`;

exports[`tree-test A tree created from a multi-level object when returned as a whole tree with values shown produces correct output 1`] = `
"
├─ oranges
│ └─ mandarin
│ ├─ clementine
│ └─ tangerine: so cheap and juicy!
└─ apples
├─ gala
└─ pink lady
"
`;

exports[`tree-test A tree created from a multi-level object when returned as a whole tree with values shown using a custom serializer produces correct output 1`] = `
"
├─ oranges
│ └─ mandarin
│ ├─ clementine: [clementine – null]
│ └─ tangerine: [tangerine – so cheap and juicy!]
└─ apples
├─ gala
└─ pink lady: [pink lady – null]
"
`;

exports[`tree-test A tree created from a multi-level object when returned line-by-line with values hidden runs the provided callback: calls 1`] = `
Array [
Array [
"├─ oranges",
],
Array [
"│ └─ mandarin",
],
Array [
"│ ├─ clementine",
],
Array [
"│ └─ tangerine",
],
Array [
"└─ apples",
],
Array [
" ├─ gala",
],
Array [
" └─ pink lady",
],
]
`;

exports[`tree-test A tree created from a multi-level object when returned line-by-line with values shown runs the provided callback: calls 1`] = `
Array [
Array [
"├─ oranges",
],
Array [
"│ └─ mandarin",
],
Array [
"│ ├─ clementine",
],
Array [
"│ └─ tangerine: so cheap and juicy!",
],
Array [
"└─ apples",
],
Array [
" ├─ gala",
],
Array [
" └─ pink lady",
],
]
`;

exports[`tree-test A tree created from a multi-level object when returned line-by-line with values shown using a custom serializer runs the provided callback: calls 1`] = `
Array [
Array [
"├─ oranges",
],
Array [
"│ └─ mandarin",
],
Array [
"│ ├─ clementine: [clementine – null]",
],
Array [
"│ └─ tangerine: [tangerine – so cheap and juicy!]",
],
Array [
"└─ apples",
],
Array [
" ├─ gala",
],
Array [
" └─ pink lady: [pink lady – null]",
],
]
`;

exports[`tree-test A tree created from a single-level object when returned as a whole tree with values hidden produces correct output 1`] = `
"
├─ apples
└─ oranges
"
`;

exports[`tree-test A tree created from a single-level object when returned as a whole tree with values shown produces correct output 1`] = `
"
├─ apples: gala
└─ oranges: mandarin
"
`;

exports[`tree-test A tree created from a single-level object when returned line-by-line with values hidden runs the provided callback: calls 1`] = `
Array [
Array [
"├─ apples",
],
Array [
"└─ oranges",
],
]
`;

exports[`tree-test A tree created from a single-level object when returned line-by-line with values shown runs the provided callback: calls 1`] = `
Array [
Array [
"├─ apples: gala",
],
Array [
"└─ oranges: mandarin",
],
]
`;

exports[`tree-test A tree created from an object containing various types when returned line-by-line with values shown runs the provided callback: calls 1`] = `
Array [
Array [
"├─ array",
],
Array [
"│ ├─ 0: one",
],
Array [
"│ └─ 1: two",
],
Array [
"├─ numeric: 42",
],
Array [
"├─ decimal: 42.24",
],
Array [
"├─ bool: false",
],
Array [
"├─ nil",
],
Array [
"├─ undef: undefined",
],
Array [
"└─ date: 2018-01-01T00:00:00.000Z",
],
]
`;

exports[`tree-test A tree created from an object with circular references when returned line-by-line with values shown runs the provided callback: calls 1`] = `
Array [
Array [
"├─ one: one",
],
Array [
"├─ two: two",
],
Array [
"└─ three (circular ref.)",
],
]
`;

exports[`tree-test A tree created from an object with empty prototype when returned as a whole tree with values hidden produces correct output 1`] = `
"
└─ foo
"
`;

exports[`tree-test A tree created from an object with empty prototype when returned as a whole tree with values shown produces correct output 1`] = `
"
└─ foo: bar
"
`;

exports[`tree-test A tree created from an object with not so circular references when returned line-by-line with values shown runs the provided callback: calls 1`] = `
Array [
Array [
"├─ one: one",
],
Array [
"├─ two",
],
Array [
"│ └─ four: four",
],
Array [
"└─ three",
],
Array [
" └─ four: four",
],
]
`;

exports[`tree-test A tree created from an object with prototyped functions when returned as a whole tree with values shown produces correct output 1`] = `
"
└─ Friendly: stuff
"
`;

exports[`tree-test A tree with functions when returned as a whole tree with values shown, but functions hidden produces correct output 1`] = `
"
├─ Friendly: stuff
└─ Another: stuff
"
`;

exports[`tree-test A tree with functions when returned line-by-line with values shown, but functions hidden runs the provided callback: calls 1`] = `
Array [
Array [
"├─ Friendly",
],
Array [
"└─ Another",
],
]
`;
Loading