@@ -8,25 +8,51 @@ const path = require('path');
8
8
describe ( 'Use skipHours' , ( ) => {
9
9
const feed = path . join ( __dirname , 'assets' , 'skiphours.rss' ) ;
10
10
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
+ } ) ;
18
32
} ) ;
33
+ } ) ;
19
34
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
+ } ) ;
23
44
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
+ } ) ;
30
56
} ) ;
31
57
} ) ;
32
58
} ) ;
@@ -65,7 +91,7 @@ describe('Use skipDays', () => {
65
91
const host = 'http://blog.nodejs.org' ;
66
92
const path = '/feed/' ;
67
93
const reader = new FeedSub ( host + path , {
68
- emitOnStart : true , skipDays : true
94
+ emitOnStart : false , skipDays : true
69
95
} ) ;
70
96
71
97
const scope = nock ( host )
0 commit comments