-
-
Notifications
You must be signed in to change notification settings - Fork 273
/
Copy pathutils.spec.js
60 lines (54 loc) · 1.47 KB
/
utils.spec.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
import {expect} from 'chai';
import { exportToPDF, sanitizeForLogs } from '../server/lib/utils';
describe("utils", () => {
it("sanitize for logs", () => {
const obj = {
user: {
name: "Xavier",
email: "xavier@gmail.com"
},
card: {
expYear: 2022,
token: "tok_32112123"
}
};
const res = sanitizeForLogs(obj);
expect(res.user.name).to.equal(obj.user.name);
expect(res.user.email).to.equal("(email obfuscated)");
expect(res.card.token).to.equal("(token obfuscated)");
expect(res.card.expYear).to.equal(obj.card.expYear);
});
it("exports PDF", function(done) {
this.timeout(10000);
const data = {
host: {
name: "WWCode",
currency: "USD"
},
expensesPerPage: [
[
{
amount: 1000,
currency: 'USD',
description: 'Pizza',
paymentProcessorFeeInHostCurrency: 5,
collective: {
slug: 'testcollective'
},
User: {
name: "Xavier",
email: "xavier@gmail.com"
}
}
]
]
}
exportToPDF("expenses", data).then(buffer => {
const expectedSize = (process.env.NODE_ENV === 'circleci') ? 27750 : 26123;
// Size varies for some reason...
console.log("PDF length is ", buffer.length, "expected length", expectedSize);
expect(buffer.length > 20000).to.be.true;
done();
});
})
});