-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.js
55 lines (44 loc) · 1.16 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
// // Test the parseAgendaFile function against stored json expectations
const Promise = require('bluebird')
const parseAgendaFile = require('./src/parse-agenda-pdf')
// Check each of these agenda dates
Promise.resolve([
'011017',
'012417',
'013117',
'020717',
'110116',
'111516',
'112916',
'120616',
'121316',
])
.each((date) => {
// Load the expected json for the agenda
const storedJSON = require(`./json/${date}.js`) // eslint-disable-line import/no-dynamic-require
// Parse the pdf file
parseAgendaFile(`./pdfs/bag${date}_agenda.pdf`)
// Check each bill
.each((bill, index) => {
// Check each of these fields
[
'itemNumber',
'id',
'title',
'sponsors',
'text',
'fiscalImpact',
'statusLog',
'question',
].forEach((field) => {
const expected = JSON.stringify(storedJSON[index][field])
const actual = JSON.stringify(bill[field])
if (expected !== actual) {
console.log('Expected:', expected)
console.log('Actual:', actual)
console.log()
throw new Error(`PARSE EXPECTATION FAILURE: agenda[${index}][${field}]`)
}
})
})
})