@@ -136,7 +136,7 @@ describe('better-tail', function () {
136136 }
137137 } )
138138
139- describe ( 'should tail file last 10 lines (default) ' , function ( ) {
139+ describe ( 'no options ' , function ( ) {
140140 function test ( target , done ) {
141141 const data = [ ]
142142
@@ -150,21 +150,21 @@ describe('better-tail', function () {
150150 } )
151151 }
152152
153- it ( 'with target file path' , function ( done ) {
153+ it ( 'should work with file path' , function ( done ) {
154154 test ( corpus . path , done )
155155 } )
156156
157- it ( 'with file descriptor' , function ( done ) {
157+ it ( 'should work with file descriptor' , function ( done ) {
158158 test ( corpus . fd , done )
159159 } )
160160
161- it ( 'with stream' , function ( done ) {
161+ it ( 'should work with file read stream' , function ( done ) {
162162 test ( corpus . rs , done )
163163 } )
164164 } )
165165
166- describe ( 'should tail file last N bytes' , function ( ) {
167- function test ( target , done ) {
166+ describe ( 'bytes option ( last bytes) ' , function ( ) {
167+ function test ( target , done , options = { } ) {
168168 // Get content length in bytes
169169 const contentByteLength = Buffer . byteLength ( corpus . expectations . content , 'utf8' )
170170
@@ -177,9 +177,9 @@ describe('better-tail', function () {
177177
178178 const data = [ ]
179179
180- new Tail ( target , {
180+ new Tail ( target , Object . assign ( options , {
181181 bytes
182- } ) . on ( 'data' , ( line ) => {
182+ } ) ) . on ( 'data' , ( line ) => {
183183 data . push ( line )
184184 } ) . on ( 'end' , ( ) => {
185185 expect ( data [ 0 ] ) . to . be . instanceof ( Buffer , 'Expected data to be an instance of Buffer' )
@@ -188,20 +188,24 @@ describe('better-tail', function () {
188188 } )
189189 }
190190
191- it ( 'with target file path' , function ( done ) {
191+ it ( 'should work with file path' , function ( done ) {
192192 test ( corpus . path , done )
193193 } )
194194
195- it ( 'with file descriptor' , function ( done ) {
195+ it ( 'should work with file descriptor' , function ( done ) {
196196 test ( corpus . fd , done )
197197 } )
198198
199- it ( 'with stream' , function ( done ) {
199+ it ( 'should work with file read stream' , function ( done ) {
200200 test ( corpus . rs , done )
201201 } )
202+
203+ it ( 'should superseed lines option' , function ( done ) {
204+ test ( corpus . path , done , { lines : 42 } )
205+ } )
202206 } )
203207
204- describe ( 'should tail file from Nth byte' , function ( ) {
208+ describe ( 'bytes option ( from byte) ' , function ( ) {
205209 function test ( target , done ) {
206210 // Get content length in bytes
207211 const contentByteLength = Buffer . byteLength ( corpus . expectations . content , 'utf8' )
@@ -226,20 +230,20 @@ describe('better-tail', function () {
226230 } )
227231 }
228232
229- it ( 'with target file path' , function ( done ) {
233+ it ( 'should work with file path' , function ( done ) {
230234 test ( corpus . path , done )
231235 } )
232236
233- it ( 'with file descriptor' , function ( done ) {
237+ it ( 'should work with file descriptor' , function ( done ) {
234238 test ( corpus . fd , done )
235239 } )
236240
237- it ( 'with stream' , function ( done ) {
241+ it ( 'should work with file read stream' , function ( done ) {
238242 test ( corpus . rs , done )
239243 } )
240244 } )
241245
242- describe ( 'should tail file last N lines' , function ( ) {
246+ describe ( 'lines option ( last lines) ' , function ( ) {
243247 function test ( target , done ) {
244248 // Get content length in bytes
245249 const contentByteLength = Buffer . byteLength ( corpus . expectations . content , 'utf8' )
@@ -271,20 +275,20 @@ describe('better-tail', function () {
271275 } )
272276 }
273277
274- it ( 'with target file path' , function ( done ) {
278+ it ( 'should work with file path' , function ( done ) {
275279 test ( corpus . path , done )
276280 } )
277281
278- it ( 'with file descriptor' , function ( done ) {
282+ it ( 'should work with file descriptor' , function ( done ) {
279283 test ( corpus . fd , done )
280284 } )
281285
282- it ( 'with stream' , function ( done ) {
286+ it ( 'should work with file read stream' , function ( done ) {
283287 test ( corpus . rs , done )
284288 } )
285289 } )
286290
287- describe ( 'should tail file from Nth line' , function ( ) {
291+ describe ( 'lines option ( from line) ' , function ( ) {
288292 function test ( target , done ) {
289293 // Get content length in bytes
290294 const contentByteLength = Buffer . byteLength ( corpus . expectations . content , 'utf8' )
@@ -315,20 +319,20 @@ describe('better-tail', function () {
315319 } )
316320 }
317321
318- it ( 'with target file path' , function ( done ) {
322+ it ( 'should work with file path' , function ( done ) {
319323 test ( corpus . path , done )
320324 } )
321325
322- it ( 'with file descriptor' , function ( done ) {
326+ it ( 'should work with file descriptor' , function ( done ) {
323327 test ( corpus . fd , done )
324328 } )
325329
326- it ( 'with stream' , function ( done ) {
330+ it ( 'should work with file read stream' , function ( done ) {
327331 test ( corpus . rs , done )
328332 } )
329333 } )
330334
331- describe ( 'follow mode ' , function ( ) {
335+ describe ( 'follow option ' , function ( ) {
332336 it ( 'should follow data quickly appended to file (backpressure)' , function ( done ) {
333337 const rndStrSize = randomInt ( )
334338
@@ -372,16 +376,26 @@ describe('better-tail', function () {
372376 } )
373377
374378 describe ( 'errors' , function ( ) {
379+ it ( 'should fail to tail undefined target' , function ( done ) {
380+ new Tail ( ) . on ( 'error' , ( err ) => {
381+ expect ( err ) . to . be . instanceof ( Error )
382+ . and . have . property ( 'message' , 'Invalid target provided' )
383+ done ( )
384+ } )
385+ } )
386+
375387 it ( 'should fail to tail invalid file' , function ( done ) {
376388 new Tail ( path . resolve ( __dirname , `${ randomString ( 10 ) } .txt` ) ) . on ( 'error' , ( err ) => {
377389 expect ( err ) . to . be . instanceof ( Error )
390+ . and . have . property ( 'code' , 'ENOENT' )
378391 done ( )
379392 } )
380393 } )
381394
382395 it ( 'should fail to tail invalid file descriptor' , function ( done ) {
383396 new Tail ( 654 ) . on ( 'error' , ( err ) => {
384397 expect ( err ) . to . be . instanceof ( Error )
398+ . and . have . property ( 'message' , 'Invalid target provided' )
385399 done ( )
386400 } )
387401 } )
0 commit comments