@@ -28,7 +28,8 @@ describe('Bulk', function () {
28
28
return setupDatabase ( this . configuration ) ;
29
29
} ) ;
30
30
describe ( 'BulkOperationBase' , ( ) => {
31
- describe ( '#raw' , function ( ) {
31
+ // eslint-disable-next-line no-restricted-properties
32
+ describe . only ( '#raw' , function ( ) {
32
33
let client ;
33
34
beforeEach ( async function ( ) {
34
35
client = this . configuration . newClient ( ) ;
@@ -44,6 +45,18 @@ describe('Bulk', function () {
44
45
expect ( ( ) => bulkOp . raw ( true ) ) . to . throw ( MongoInvalidArgumentError ) ;
45
46
expect ( ( ) => bulkOp . raw ( 3 ) ) . to . throw ( MongoInvalidArgumentError ) ;
46
47
} ) ;
48
+
49
+ it ( 'should throw an error with the specifc message: "Operation must be an object with an operation key"' , async function ( ) {
50
+ const bulkOp = client . db ( 'test' ) . collection ( 'test' ) . initializeUnorderedBulkOp ( ) ;
51
+ try {
52
+ bulkOp . raw ( undefined ) ;
53
+ expect . fail (
54
+ 'Expected passing argument of "undefined" to .raw to throw error, failed to throw error'
55
+ ) ;
56
+ } catch ( error ) {
57
+ expect ( error . message ) . to . equal ( 'Operation must be an object with an operation key' ) ;
58
+ }
59
+ } ) ;
47
60
} ) ;
48
61
49
62
context ( 'when called with a valid operation' , function ( ) {
@@ -58,6 +71,8 @@ describe('Bulk', function () {
58
71
} ) ;
59
72
} ) ;
60
73
74
+ //write test to check if error thrown at raw op hasnt changed
75
+
61
76
describe ( 'Db.collection' , function ( ) {
62
77
describe ( '#insertMany' , function ( ) {
63
78
let client ;
@@ -68,8 +83,8 @@ describe('Bulk', function () {
68
83
afterEach ( async function ( ) {
69
84
await client . close ( ) ;
70
85
} ) ;
71
- context ( 'when passed an invalid or sparse list ' , function ( ) {
72
- it ( 'insertMany should throw a MongoInvalidArgument error when called with a valid operation' , async function ( ) {
86
+ context ( 'when passed an invalid docs argument ' , function ( ) {
87
+ it ( 'insertMany should throw a MongoInvalidArgument error when called with a invalid operation' , async function ( ) {
73
88
try {
74
89
const docs = [ ] ;
75
90
docs [ 1 ] = { color : 'red' } ;
0 commit comments