@@ -436,6 +436,65 @@ describe("Documents", function () {
436
436
} ) ;
437
437
438
438
describe ( ".import" , function ( ) {
439
+ context ( "when an empty array of documents is passed" , function ( ) {
440
+ it ( "throws RequestMalformed error" , function ( done ) {
441
+ documents
442
+ . import ( [ ] )
443
+ . then ( ( ) => {
444
+ done ( new Error ( "Expected import to throw RequestMalformed error" ) ) ;
445
+ } )
446
+ . catch ( ( error ) => {
447
+ expect ( error . constructor . name ) . to . eq ( "RequestMalformed" ) ;
448
+ expect ( error . message ) . to . eq ( "No documents provided" ) ;
449
+ done ( ) ;
450
+ } ) ;
451
+ } ) ;
452
+ } ) ;
453
+
454
+ context ( "when an empty string is passed" , function ( ) {
455
+ it ( "throws RequestMalformed error" , function ( done ) {
456
+ documents
457
+ . import ( "" )
458
+ . then ( ( ) => {
459
+ done ( new Error ( "Expected import to throw RequestMalformed error" ) ) ;
460
+ } )
461
+ . catch ( ( error ) => {
462
+ expect ( error . constructor . name ) . to . eq ( "RequestMalformed" ) ;
463
+ expect ( error . message ) . to . eq ( "No documents provided" ) ;
464
+ done ( ) ;
465
+ } ) ;
466
+ } ) ;
467
+ } ) ;
468
+
469
+ context ( "when null is passed as JSONL string" , function ( ) {
470
+ it ( "throws RequestMalformed error" , function ( done ) {
471
+ documents
472
+ . import ( null )
473
+ . then ( ( ) => {
474
+ done ( new Error ( "Expected import to throw RequestMalformed error" ) ) ;
475
+ } )
476
+ . catch ( ( error ) => {
477
+ expect ( error . constructor . name ) . to . eq ( "RequestMalformed" ) ;
478
+ expect ( error . message ) . to . eq ( "No documents provided" ) ;
479
+ done ( ) ;
480
+ } ) ;
481
+ } ) ;
482
+ } ) ;
483
+
484
+ context ( "when undefined is passed as JSONL string" , function ( ) {
485
+ it ( "throws RequestMalformed error" , function ( done ) {
486
+ documents
487
+ . import ( undefined )
488
+ . then ( ( ) => {
489
+ done ( new Error ( "Expected import to throw RequestMalformed error" ) ) ;
490
+ } )
491
+ . catch ( ( error ) => {
492
+ expect ( error . constructor . name ) . to . eq ( "RequestMalformed" ) ;
493
+ expect ( error . message ) . to . eq ( "No documents provided" ) ;
494
+ done ( ) ;
495
+ } ) ;
496
+ } ) ;
497
+ } ) ;
439
498
context ( "when a query paramater is passed" , function ( ) {
440
499
it ( "passes the query parameter to the API" , function ( done ) {
441
500
mockAxios
0 commit comments