@@ -8,25 +8,51 @@ const path = require('path');
88describe ( 'Use skipHours' , ( ) => {
99 const feed = path . join ( __dirname , 'assets' , 'skiphours.rss' ) ;
1010 describe ( 'With hours that match time now' , ( ) => {
11- it ( 'Should return no items' , ( done ) => {
12- muk ( Date . prototype , 'getHours' , ( ) => 4 ) ;
13- after ( muk . restore ) ;
14- const host = 'http://www.google.com' ;
15- const path = '/reader/public/atom/' ;
16- const reader = new FeedSub ( host + path , {
17- emitOnStart : true , skipHours : true
11+ describe ( 'With `emitOnStart`' , ( ) => {
12+ it ( 'Should return some items' , ( done ) => {
13+ muk ( Date . prototype , 'getHours' , ( ) => 4 ) ;
14+ after ( muk . restore ) ;
15+ const host = 'http://www.google.com' ;
16+ const path = '/reader/public/atom/' ;
17+ const reader = new FeedSub ( host + path , {
18+ emitOnStart : true , skipHours : true
19+ } ) ;
20+
21+ const scope = nock ( host )
22+ . get ( path )
23+ . replyWithFile ( 200 , feed ) ;
24+
25+ reader . read ( ( err , items ) => {
26+ assert . ifError ( err ) ;
27+ assert . ok ( Array . isArray ( items ) ) ;
28+ assert . equal ( items . length , 20 ) ;
29+ scope . done ( ) ;
30+ done ( ) ;
31+ } ) ;
1832 } ) ;
33+ } ) ;
1934
20- const scope = nock ( host )
21- . get ( path )
22- . replyWithFile ( 200 , feed ) ;
35+ describe ( 'Without `emitOnStart`' , ( ) => {
36+ it ( 'Should return no items' , ( done ) => {
37+ muk ( Date . prototype , 'getHours' , ( ) => 4 ) ;
38+ after ( muk . restore ) ;
39+ const host = 'http://www.google.com' ;
40+ const path = '/reader/public/atom/' ;
41+ const reader = new FeedSub ( host + path , {
42+ emitOnStart : false , skipHours : true
43+ } ) ;
2344
24- reader . read ( ( err , items ) => {
25- assert . ifError ( err ) ;
26- assert . ok ( Array . isArray ( items ) ) ;
27- assert . equal ( items . length , 0 ) ;
28- scope . done ( ) ;
29- done ( ) ;
45+ const scope = nock ( host )
46+ . get ( path )
47+ . replyWithFile ( 200 , feed ) ;
48+
49+ reader . read ( ( err , items ) => {
50+ assert . ifError ( err ) ;
51+ assert . ok ( Array . isArray ( items ) ) ;
52+ assert . equal ( items . length , 0 ) ;
53+ scope . done ( ) ;
54+ done ( ) ;
55+ } ) ;
3056 } ) ;
3157 } ) ;
3258 } ) ;
@@ -65,7 +91,7 @@ describe('Use skipDays', () => {
6591 const host = 'http://blog.nodejs.org' ;
6692 const path = '/feed/' ;
6793 const reader = new FeedSub ( host + path , {
68- emitOnStart : true , skipDays : true
94+ emitOnStart : false , skipDays : true
6995 } ) ;
7096
7197 const scope = nock ( host )
0 commit comments