Skip to content

Commit 51ba348

Browse files
author
Andrey
committed
Added additional tests
- Conversion test - Generate a new PDF test - Text extract test
1 parent d1c2128 commit 51ba348

File tree

6 files changed

+41
-0
lines changed

6 files changed

+41
-0
lines changed

files/document.docx.pdf

19 Bytes
Binary file not shown.

files/new.pdf

-72 Bytes
Binary file not shown.

files/optimized_webviewer.pdf

3 Bytes
Binary file not shown.

files/webviewer.pdf-1.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
6 Important Factors when
2+
Choosing a PDF Library
3+
ADAM PEZ

modules/mimeType.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ module.exports = mimeType = {
1616
'.doc': 'application/msword',
1717
'.eot': 'application/vnd.ms-fontobject',
1818
'.ttf': 'application/x-font-ttf',
19+
'.txt': 'text/plain',
1920
};

test/test.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,40 @@ describe('/GET thumbnail/filename', () => {
5353
});
5454
});
5555
});
56+
57+
describe('/GET convert/filename', () => {
58+
it('it should GET a converted PDF document', (done) => {
59+
chai.request(server)
60+
.get('/convert/document.docx')
61+
.end((err, res) => {
62+
chai.expect(res.status).to.equal(200);
63+
chai.expect(res.type).to.equal(mimeType['.pdf']);
64+
done();
65+
});
66+
});
67+
});
68+
69+
describe('/GET generate/filename', () => {
70+
it('it should GET a newly generated PDF document', (done) => {
71+
chai.request(server)
72+
.get('/generate/new')
73+
.end((err, res) => {
74+
chai.expect(res.status).to.equal(200);
75+
chai.expect(res.type).to.equal(mimeType['.pdf']);
76+
done();
77+
});
78+
});
79+
});
80+
81+
describe('/GET textextract/filename', () => {
82+
it('it should GET text from PDF page 1', (done) => {
83+
chai.request(server)
84+
.get('/textextract/webviewer.pdf-1')
85+
.end((err, res) => {
86+
chai.expect(res.status).to.equal(200);
87+
chai.expect(res.type).to.equal(mimeType['.txt']);
88+
chai.expect(res.text).to.equal('6 Important Factors when\nChoosing a PDF Library\nADAM PEZ\n');
89+
done();
90+
});
91+
});
92+
});

0 commit comments

Comments
 (0)