File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 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+ } ) ;
You can’t perform that action at this time.
0 commit comments