-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
78 lines (53 loc) · 1.29 KB
/
test.js
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
'use strict'
const test = require('tape')
const concat = require('concat-stream')
const sheet = require('.')
test('basic', function (t) {
t.plan(1)
const stream = sheet()
stream.pipe(concat(function (data) {
t.same(data, [{ a: 0.3, b: null, c: -2 }, { a: 'a', b: 'b', c: 'c' }])
}))
// Same test as excel-stream
stream.end('a,b,c\n0.3,,-2\na,b,c')
})
test('only headers', function (t) {
t.plan(1)
const stream = sheet()
stream.pipe(concat(function (data) {
t.same(data, [])
}))
stream.end('beep,boop')
})
test('empty', function (t) {
t.plan(1)
const stream = sheet()
stream.pipe(concat(function (data) {
t.same(data, [])
}))
stream.end()
})
test('maxSize', function (t) {
t.plan(1)
const stream = sheet({ maxSize: 1 })
stream.on('error', function (err) {
t.is(err.message, 'Maximum size exceeded: 1')
})
stream.end('xyz')
})
test('non existent sheet', function (t) {
t.plan(1)
const stream = sheet({ sheet: 'no' })
stream.on('error', function (err) {
t.is(err.message, 'Sheet not found')
})
stream.end('xyz')
})
test('non existent sheetIndex', function (t) {
t.plan(1)
const stream = sheet({ sheetIndex: 2 })
stream.on('error', function (err) {
t.is(err.message, 'Sheet not found')
})
stream.end('xyz')
})