@@ -32,7 +32,7 @@ describe('hn', function(){
3232 return done ( "Error" ) ;
3333 }
3434 expect ( data ) . to . have . property ( 'hits' ) ;
35- data . hits . map ( function ( comment ) {
35+ data . hits . forEach ( function ( comment ) {
3636 var intersection = tags . filter ( function ( n ) {
3737 return comment . _tags . indexOf ( n ) != - 1 ;
3838 } ) ;
@@ -41,6 +41,19 @@ describe('hn', function(){
4141 done ( ) ;
4242 }
4343
44+ function verifyDataHasAllOfTags ( err , data , tags , done ) {
45+ if ( err ) {
46+ return done ( "Error" ) ;
47+ }
48+ expect ( data ) . to . have . property ( 'hits' ) ;
49+ data . hits . forEach ( function ( item ) {
50+ tags . forEach ( function ( tag ) {
51+ expect ( item . _tags ) . to . contain ( tag ) ;
52+ } ) ;
53+ } ) ;
54+ done ( ) ;
55+ }
56+
4457 it ( 'should get comments' , function ( done ) {
4558 hn . getComments ( crazy_curry ( [ 'comment' ] , done , verifyDataHasOneOfTags ) ) ;
4659 } ) ;
@@ -71,4 +84,79 @@ describe('hn', function(){
7184 it ( 'should get latest stories' , function ( done ) {
7285 hn . getLastStories ( crazy_curry ( [ 'story' ] , done , verifyDataHasOneOfTags ) ) ;
7386 } ) ;
87+
88+ it ( 'should get item' , function ( done ) {
89+ hn . getItem ( 17 , function ( err , res ) {
90+ if ( err ) return done ( err ) ;
91+ expect ( res . id ) . to . equal ( 17 ) ;
92+ expect ( res . type ) . to . equal ( 'comment' ) ;
93+ done ( ) ;
94+ } ) ;
95+ } ) ;
96+
97+ it ( 'should get user' , function ( done ) {
98+ hn . getUser ( 'pg' , function ( err , res ) {
99+ if ( err ) return done ( err ) ;
100+ expect ( res . username ) . to . equal ( 'pg' ) ;
101+ done ( ) ;
102+ } ) ;
103+ } ) ;
104+
105+ it ( 'should get user comments' , function ( done ) {
106+ hn . getUserComments ( 'pg' , crazy_curry ( [ 'comment' , 'author_pg' ] , done , verifyDataHasAllOfTags ) ) ;
107+ } ) ;
108+ it ( 'should get last user comments' , function ( done ) {
109+ hn . getLastUserComments ( 'pg' , crazy_curry ( [ 'comment' , 'author_pg' ] , done , verifyDataHasAllOfTags ) ) ;
110+ } ) ;
111+
112+ it ( 'should get user polls' , function ( done ) {
113+ hn . getUserPolls ( 'pg' , crazy_curry ( [ 'poll' , 'author_pg' ] , done , verifyDataHasAllOfTags ) ) ;
114+ } ) ;
115+ it ( 'should get last user polls' , function ( done ) {
116+ hn . getLastUserPolls ( 'pg' , crazy_curry ( [ 'poll' , 'author_pg' ] , done , verifyDataHasAllOfTags ) ) ;
117+ } ) ;
118+
119+ it ( 'should get user stories' , function ( done ) {
120+ hn . getUserStories ( 'pg' , crazy_curry ( [ 'story' , 'author_pg' ] , done , verifyDataHasAllOfTags ) ) ;
121+ } ) ;
122+ it ( 'should get last user stories' , function ( done ) {
123+ hn . getLastUserStories ( 'pg' , crazy_curry ( [ 'story' , 'author_pg' ] , done , verifyDataHasAllOfTags ) ) ;
124+ } ) ;
125+
126+ it ( 'should search comments' , function ( done ) {
127+ hn . searchComments ( 'apple' , crazy_curry ( [ 'comment' ] , done , verifyDataHasAllOfTags ) ) ;
128+ } ) ;
129+ it ( 'should search last comments' , function ( done ) {
130+ hn . searchLastComments ( 'apple' , crazy_curry ( [ 'comment' ] , done , verifyDataHasAllOfTags ) ) ;
131+ } ) ;
132+
133+ it ( 'should search polls' , function ( done ) {
134+ hn . searchPolls ( 'apple' , crazy_curry ( [ 'poll' ] , done , verifyDataHasAllOfTags ) ) ;
135+ } ) ;
136+ it ( 'should search last polls' , function ( done ) {
137+ hn . searchLastPolls ( 'apple' , crazy_curry ( [ 'poll' ] , done , verifyDataHasAllOfTags ) ) ;
138+ } ) ;
139+
140+
141+ it ( 'should search posts' , function ( done ) {
142+ hn . searchPosts ( 'apple' , crazy_curry ( [ 'story' ] , done , verifyDataHasAllOfTags ) ) ;
143+ } ) ;
144+ it ( 'should search last posts' , function ( done ) {
145+ hn . searchLastPosts ( 'apple' , crazy_curry ( [ 'story' ] , done , verifyDataHasAllOfTags ) ) ;
146+ } ) ;
147+
148+ it ( 'should search posts' , function ( done ) {
149+ hn . searchStories ( 'apple' , crazy_curry ( [ 'story' ] , done , verifyDataHasAllOfTags ) ) ;
150+ } ) ;
151+ it ( 'should search last posts' , function ( done ) {
152+ hn . searchLastStories ( 'apple' , crazy_curry ( [ 'story' ] , done , verifyDataHasAllOfTags ) ) ;
153+ } ) ;
154+
155+ it ( 'should search' , function ( done ) {
156+ hn . search ( { tags : 'ask_hn' , query : 'apple' , page : 2 } , crazy_curry ( [ 'ask_hn' ] , done , verifyDataHasAllOfTags ) ) ;
157+ } ) ;
158+ it ( 'should search last' , function ( done ) {
159+ hn . searchLast ( { tags : 'ask_hn' , query : 'apple' , page : 2 } , crazy_curry ( [ 'ask_hn' ] , done , verifyDataHasAllOfTags ) ) ;
160+ } ) ;
161+
74162} ) ;
0 commit comments