@@ -34,7 +34,7 @@ describe('Language', function() {
3434 var BUCKET ;
3535
3636 var TEXT_CONTENT_SENTENCES = [
37- 'Hello from stephen and dave !' ,
37+ 'Hello from stephen and david !' ,
3838 'If you find yourself in michigan, come say hi!'
3939 ] ;
4040
@@ -313,150 +313,182 @@ describe('Language', function() {
313313
314314 function validateAnnotationSimple ( callback ) {
315315 return function ( err , annotation , apiResponse ) {
316- assert . ifError ( err ) ;
316+ try {
317+ assert . ifError ( err ) ;
317318
318- assert . strictEqual ( annotation . language , 'en' ) ;
319+ assert . strictEqual ( annotation . language , 'en' ) ;
319320
320- assert ( is . number ( annotation . sentiment ) ) ;
321+ assert ( is . number ( annotation . sentiment ) ) ;
321322
322- assert . deepEqual ( annotation . entities , {
323- people : [ 'stephen' , 'dave ' ] ,
324- places : [ 'michigan' ]
325- } ) ;
323+ assert . deepEqual ( annotation . entities , {
324+ people : [ 'stephen' , 'david ' ] ,
325+ places : [ 'michigan' ]
326+ } ) ;
326327
327- assert . deepEqual ( annotation . sentences , TEXT_CONTENT_SENTENCES ) ;
328+ assert . deepEqual ( annotation . sentences , TEXT_CONTENT_SENTENCES ) ;
328329
329- assert ( is . array ( annotation . tokens ) ) ;
330- assert . deepEqual ( annotation . tokens [ 0 ] , {
331- text : 'Hello' ,
332- partOfSpeech : 'Other: foreign words, typos, abbreviations' ,
333- partOfSpeechTag : 'X'
334- } ) ;
330+ assert ( is . array ( annotation . tokens ) ) ;
331+ assert . deepEqual ( annotation . tokens [ 0 ] , {
332+ text : 'Hello' ,
333+ partOfSpeech : 'Other: foreign words, typos, abbreviations' ,
334+ partOfSpeechTag : 'X'
335+ } ) ;
335336
336- assert ( is . object ( apiResponse ) ) ;
337+ assert ( is . object ( apiResponse ) ) ;
337338
338- callback ( ) ;
339+ callback ( ) ;
340+ } catch ( e ) {
341+ callback ( e ) ;
342+ }
339343 } ;
340344 }
341345
342346 function validateAnnotationVerbose ( callback ) {
343347 return function ( err , annotation , apiResponse ) {
344- assert . ifError ( err ) ;
348+ try {
349+ assert . ifError ( err ) ;
345350
346- assert . strictEqual ( annotation . language , 'en' ) ;
351+ assert . strictEqual ( annotation . language , 'en' ) ;
347352
348- assert ( is . object ( annotation . sentiment ) ) ;
353+ assert ( is . object ( annotation . sentiment ) ) ;
349354
350- assert ( is . array ( annotation . entities . people ) ) ;
351- assert . strictEqual ( annotation . entities . people . length , 2 ) ;
352- assert ( is . object ( annotation . entities . people [ 0 ] ) ) ;
355+ assert ( is . array ( annotation . entities . people ) ) ;
356+ assert . strictEqual ( annotation . entities . people . length , 2 ) ;
357+ assert ( is . object ( annotation . entities . people [ 0 ] ) ) ;
353358
354- assert ( is . array ( annotation . sentences ) ) ;
355- assert ( is . object ( annotation . sentences [ 0 ] ) ) ;
359+ assert ( is . array ( annotation . sentences ) ) ;
360+ assert ( is . object ( annotation . sentences [ 0 ] ) ) ;
356361
357- assert ( is . array ( annotation . tokens ) ) ;
358- assert ( is . object ( annotation . tokens [ 0 ] ) ) ;
359- assert . strictEqual ( annotation . tokens [ 0 ] . text . content , 'Hello' ) ;
362+ assert ( is . array ( annotation . tokens ) ) ;
363+ assert ( is . object ( annotation . tokens [ 0 ] ) ) ;
364+ assert . strictEqual ( annotation . tokens [ 0 ] . text . content , 'Hello' ) ;
360365
361- assert ( is . object ( apiResponse ) ) ;
366+ assert ( is . object ( apiResponse ) ) ;
362367
363- callback ( ) ;
368+ callback ( ) ;
369+ } catch ( e ) {
370+ callback ( e ) ;
371+ }
364372 } ;
365373 }
366374
367375 function validateAnnotationSingleFeatureSimple ( callback ) {
368376 return function ( err , annotation , apiResponse ) {
369- assert . ifError ( err ) ;
377+ try {
378+ assert . ifError ( err ) ;
370379
371- assert . strictEqual ( annotation . language , 'en' ) ;
380+ assert . strictEqual ( annotation . language , 'en' ) ;
372381
373- assert . deepEqual ( annotation . entities , {
374- people : [ 'stephen' , 'dave ' ] ,
375- places : [ 'michigan' ]
376- } ) ;
382+ assert . deepEqual ( annotation . entities , {
383+ people : [ 'stephen' , 'david ' ] ,
384+ places : [ 'michigan' ]
385+ } ) ;
377386
378- assert . strictEqual ( annotation . sentences , undefined ) ;
379- assert . strictEqual ( annotation . sentiment , undefined ) ;
380- assert . strictEqual ( annotation . tokens , undefined ) ;
387+ assert . strictEqual ( annotation . sentences , undefined ) ;
388+ assert . strictEqual ( annotation . sentiment , undefined ) ;
389+ assert . strictEqual ( annotation . tokens , undefined ) ;
381390
382- assert ( is . object ( apiResponse ) ) ;
391+ assert ( is . object ( apiResponse ) ) ;
383392
384- callback ( ) ;
393+ callback ( ) ;
394+ } catch ( e ) {
395+ callback ( e ) ;
396+ }
385397 } ;
386398 }
387399
388400 function validateAnnotationSingleFeatureVerbose ( callback ) {
389401 return function ( err , annotation , apiResponse ) {
390- assert . ifError ( err ) ;
402+ try {
403+ assert . ifError ( err ) ;
391404
392- assert . strictEqual ( annotation . language , 'en' ) ;
405+ assert . strictEqual ( annotation . language , 'en' ) ;
393406
394- assert ( is . array ( annotation . entities . people ) ) ;
395- assert . strictEqual ( annotation . entities . people . length , 2 ) ;
396- assert ( is . object ( annotation . entities . people [ 0 ] ) ) ;
407+ assert ( is . array ( annotation . entities . people ) ) ;
408+ assert . strictEqual ( annotation . entities . people . length , 2 ) ;
409+ assert ( is . object ( annotation . entities . people [ 0 ] ) ) ;
397410
398- assert . strictEqual ( annotation . sentences , undefined ) ;
399- assert . strictEqual ( annotation . sentiment , undefined ) ;
400- assert . strictEqual ( annotation . tokens , undefined ) ;
411+ assert . strictEqual ( annotation . sentences , undefined ) ;
412+ assert . strictEqual ( annotation . sentiment , undefined ) ;
413+ assert . strictEqual ( annotation . tokens , undefined ) ;
401414
402- assert ( is . object ( apiResponse ) ) ;
415+ assert ( is . object ( apiResponse ) ) ;
403416
404- callback ( ) ;
417+ callback ( ) ;
418+ } catch ( e ) {
419+ callback ( e ) ;
420+ }
405421 } ;
406422 }
407423
408424 function validateEntitiesSimple ( callback ) {
409425 return function ( err , entities , apiResponse ) {
410- assert . ifError ( err ) ;
426+ try {
427+ assert . ifError ( err ) ;
411428
412- assert . deepEqual ( entities , {
413- people : [ 'stephen' , 'dave ' ] ,
414- places : [ 'michigan' ]
415- } ) ;
429+ assert . deepEqual ( entities , {
430+ people : [ 'stephen' , 'david ' ] ,
431+ places : [ 'michigan' ]
432+ } ) ;
416433
417- assert ( is . object ( apiResponse ) ) ;
434+ assert ( is . object ( apiResponse ) ) ;
418435
419- callback ( ) ;
436+ callback ( ) ;
437+ } catch ( e ) {
438+ callback ( e ) ;
439+ }
420440 } ;
421441 }
422442
423443 function validateEntitiesVerbose ( callback ) {
424444 return function ( err , entities , apiResponse ) {
425- assert . ifError ( err ) ;
445+ try {
446+ assert . ifError ( err ) ;
426447
427- assert ( is . array ( entities . people ) ) ;
428- assert . strictEqual ( entities . people . length , 2 ) ;
429- assert ( is . object ( entities . people [ 0 ] ) ) ;
448+ assert ( is . array ( entities . people ) ) ;
449+ assert . strictEqual ( entities . people . length , 2 ) ;
450+ assert ( is . object ( entities . people [ 0 ] ) ) ;
430451
431- assert ( is . object ( apiResponse ) ) ;
452+ assert ( is . object ( apiResponse ) ) ;
432453
433- callback ( ) ;
454+ callback ( ) ;
455+ } catch ( e ) {
456+ callback ( e ) ;
457+ }
434458 } ;
435459 }
436460
437461 function validateSentimentSimple ( callback ) {
438462 return function ( err , sentiment , apiResponse ) {
439- assert . ifError ( err ) ;
463+ try {
464+ assert . ifError ( err ) ;
440465
441- assert ( is . number ( sentiment ) ) ;
466+ assert ( is . number ( sentiment ) ) ;
442467
443- assert ( is . object ( apiResponse ) ) ;
468+ assert ( is . object ( apiResponse ) ) ;
444469
445- callback ( ) ;
470+ callback ( ) ;
471+ } catch ( e ) {
472+ callback ( e ) ;
473+ }
446474 } ;
447475 }
448476
449477 function validateSentimentVerbose ( callback ) {
450478 return function ( err , sentiment , apiResponse ) {
451- assert . ifError ( err ) ;
479+ try {
480+ assert . ifError ( err ) ;
452481
453- assert ( is . object ( sentiment ) ) ;
454- assert ( is . number ( sentiment . polarity ) ) ;
455- assert ( is . number ( sentiment . magnitude ) ) ;
482+ assert ( is . object ( sentiment ) ) ;
483+ assert ( is . number ( sentiment . polarity ) ) ;
484+ assert ( is . number ( sentiment . magnitude ) ) ;
456485
457- assert ( is . object ( apiResponse ) ) ;
486+ assert ( is . object ( apiResponse ) ) ;
458487
459- callback ( ) ;
488+ callback ( ) ;
489+ } catch ( e ) {
490+ callback ( e ) ;
491+ }
460492 } ;
461493 }
462494} ) ;
0 commit comments