Skip to content

Commit 5a71889

Browse files
author
Ammar Dodin
committed
💚 add unit tests for lib/to-promise.ts
1 parent 538bb72 commit 5a71889

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

test/unit/test.toPromise.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
const toPromise = require('../../lib/to-promise');
2+
const stream = require('stream');
3+
const fs = require('fs');
4+
const assert = require('assert');
5+
const path = require('path');
6+
7+
describe('toPromise()', () => {
8+
it('should resolve with results buffer as a string', () => {
9+
const file = fs.createReadStream(
10+
path.join(__dirname, '../resources/weather_data_train.csv')
11+
);
12+
toPromise(file)
13+
.then(res => {
14+
assert(typeof res === 'string');
15+
})
16+
.catch(err => {
17+
console.log(err);
18+
assert(false);
19+
});
20+
});
21+
it('should resolve with results string as an array', () => {
22+
const file = fs.createReadStream(
23+
path.join(__dirname, '../resources/weather_data_train.csv')
24+
);
25+
file.setEncoding('utf-8');
26+
toPromise(file)
27+
.then(res => {
28+
assert(res instanceof Array);
29+
})
30+
.catch(err => {
31+
assert(false);
32+
});
33+
});
34+
});

0 commit comments

Comments
 (0)