-
Notifications
You must be signed in to change notification settings - Fork 68
/
table.e2e.ts
47 lines (41 loc) · 1.57 KB
/
table.e2e.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import {expect, fancy} from 'fancy-test'
import {CliUx} from '../../../src'
describe('styled/table', () => {
describe('null/undefined handling', () => {
fancy
.stdout()
.end('omits nulls and undefined by default', output => {
const data = [{a: 1, b: '2', c: null, d: undefined}]
CliUx.ux.table(data, {a: {}, b: {}, c: {}, d: {}})
expect(output.stdout).to.include('1')
expect(output.stdout).to.include('2')
expect(output.stdout).to.not.include('null')
expect(output.stdout).to.not.include('undefined')
})
})
describe('scale tests', () => {
const bigRows = 150_000
fancy
.stdout()
.end('very tall tables don\'t exceed stack depth', output => {
const data = Array.from({length: bigRows}).fill({id: '123', name: 'foo', value: 'bar'}) as Record<string, unknown>[]
const tallColumns = {
id: {header: 'ID'},
name: {},
value: {header: 'TEST'},
}
CliUx.ux.table(data, tallColumns)
expect(output.stdout).to.include('ID')
})
fancy
.stdout()
.end('very tall, wide tables don\'t exceed stack depth', output => {
const columns = 100
const row = Object.fromEntries(Array.from({length: columns}).map((_, i) => [`col${i}`, 'foo']))
const data = Array.from({length: bigRows}).fill(row) as Record<string, unknown>[]
const bigColumns = Object.fromEntries(Array.from({length: columns}).map((_, i) => [`col${i}`, {header: `col${i}`.toUpperCase()}]))
CliUx.ux.table(data, bigColumns)
expect(output.stdout).to.include('COL1')
})
})
})