@@ -25,7 +25,7 @@ function createPreviewApiClient() {
2525
2626describe ( 'Api' , function ( ) {
2727
28- this . timeout ( 5000 ) ;
28+ this . timeout ( "30s" ) ;
2929
3030 /* GET API CLIENT */
3131 it ( 'should return an api client object from getApi' , function ( done ) {
@@ -191,6 +191,109 @@ describe('Api', function() {
191191 done ( ) ;
192192 } )
193193
194+ it ( 'should throw error if take parameter is NOT a number in getContentList' , function ( done ) {
195+ expect ( function ( ) {
196+ var api = createApiClient ( ) ;
197+ api . getContentList ( {
198+ referenceName : 'posts' ,
199+ take : 'ten'
200+ } )
201+ . then ( function ( contentList ) {
202+ assert . strictEqual ( contentList [ 0 ] . contentID , 24 ) ;
203+ assert . strictEqual ( contentList [ 1 ] . contentID , 25 ) ;
204+ done ( ) ;
205+ } )
206+ . catch ( done ) ;
207+ } ) . to . throw ( TypeError ) ;
208+ done ( ) ;
209+ } )
210+
211+ it ( 'should throw error if take parameter is a number less than 1 in getContentList' , function ( done ) {
212+ expect ( function ( ) {
213+ var api = createApiClient ( ) ;
214+ api . getContentList ( {
215+ referenceName : 'posts' ,
216+ take : 0
217+ } )
218+ . then ( function ( contentList ) {
219+ assert . strictEqual ( contentList [ 0 ] . contentID , 24 ) ;
220+ assert . strictEqual ( contentList [ 1 ] . contentID , 25 ) ;
221+ done ( ) ;
222+ } )
223+ . catch ( done ) ;
224+ } ) . to . throw ( TypeError ) ;
225+ done ( ) ;
226+ } )
227+
228+ it ( 'should throw error if take parameter is a number greater than 50 in getContentList' , function ( done ) {
229+ expect ( function ( ) {
230+ var api = createApiClient ( ) ;
231+ api . getContentList ( {
232+ referenceName : 'posts' ,
233+ take : 51
234+ } )
235+ . then ( function ( contentList ) {
236+ assert . strictEqual ( contentList [ 0 ] . contentID , 24 ) ;
237+ assert . strictEqual ( contentList [ 1 ] . contentID , 25 ) ;
238+ done ( ) ;
239+ } )
240+ . catch ( done ) ;
241+ } ) . to . throw ( TypeError ) ;
242+ done ( ) ;
243+ } )
244+
245+ it ( 'should throw error if skip parameter is a number less than 0 in getContentList' , function ( done ) {
246+ expect ( function ( ) {
247+ var api = createApiClient ( ) ;
248+ api . getContentList ( {
249+ referenceName : 'posts' ,
250+ skip : - 1
251+ } )
252+ . then ( function ( contentList ) {
253+ assert . strictEqual ( contentList [ 0 ] . contentID , 24 ) ;
254+ assert . strictEqual ( contentList [ 1 ] . contentID , 25 ) ;
255+ done ( ) ;
256+ } )
257+ . catch ( done ) ;
258+ } ) . to . throw ( TypeError ) ;
259+ done ( ) ;
260+ } )
261+
262+ it ( 'should throw error if skip parameter is NOT a number in getContentList' , function ( done ) {
263+ expect ( function ( ) {
264+ var api = createApiClient ( ) ;
265+ api . getContentList ( {
266+ referenceName : 'posts' ,
267+ skip : 'ten'
268+ } )
269+ . then ( function ( contentList ) {
270+ assert . strictEqual ( contentList [ 0 ] . contentID , 24 ) ;
271+ assert . strictEqual ( contentList [ 1 ] . contentID , 25 ) ;
272+ done ( ) ;
273+ } )
274+ . catch ( done ) ;
275+ } ) . to . throw ( TypeError ) ;
276+ done ( ) ;
277+ } )
278+
279+ it ( 'should throw error if direction parameter is NOT "asc" or "desc" in getContentList' , function ( done ) {
280+ expect ( function ( ) {
281+ var api = createApiClient ( ) ;
282+ api . getContentList ( {
283+ referenceName : 'posts' ,
284+ sort : 'fields.title' ,
285+ direction : 'up'
286+ } )
287+ . then ( function ( contentList ) {
288+ assert . strictEqual ( contentList [ 0 ] . contentID , 24 ) ;
289+ assert . strictEqual ( contentList [ 1 ] . contentID , 25 ) ;
290+ done ( ) ;
291+ } )
292+ . catch ( done ) ;
293+ } ) . to . throw ( TypeError ) ;
294+ done ( ) ;
295+ } )
296+
194297 /* GET PAGE *********************************************************/
195298 it ( 'should retrieve a page in live mode' , function ( done ) {
196299 var api = createApiClient ( ) ;
0 commit comments