this repo has no description
1import assert from 'node:assert'
2import { describe, test } from 'node:test'
3import { treeify } from './index.js'
4
5describe('readme examples', () => {
6 test('basic example', () => {
7 const eagan = [
8 'Kier Eagan',
9 ['...', ['...', 'Jame Eagan', ['Helena Eagan']], 'Ambrose Eagan'],
10 ]
11 const expected = `Kier Eagan
12├─ ...
13│ ├─ ...
14│ └─ Jame Eagan
15│ └─ Helena Eagan
16└─ Ambrose Eagan`
17
18 const result = treeify(eagan)
19 console.log('\nBasic example:')
20 console.log(result)
21 assert.strictEqual(result, expected)
22 })
23
24 test('nested example', () => {
25 const orgChart = [
26 'Lumon Industries',
27 [
28 'Board of Directors',
29 ['Natalie (Representative)'],
30 'Department Heads',
31 [
32 'Cobel (MDR)',
33 ['Milchick', 'Mark S.', ['Dylan G.', 'Irving B.', 'Helly R.']],
34 ],
35 ],
36 ]
37 const expected = `Lumon Industries
38├─ Board of Directors
39│ └─ Natalie (Representative)
40└─ Department Heads
41 └─ Cobel (MDR)
42 ├─ Milchick
43 └─ Mark S.
44 ├─ Dylan G.
45 ├─ Irving B.
46 └─ Helly R.`
47
48 const result = treeify(orgChart)
49 console.log('\nNested example:')
50 console.log(result)
51 assert.strictEqual(result, expected)
52 })
53})