11import { expect } from 'chai' ;
2- import { MongoCrypt , MongoCryptContext , MongoCryptContextCtor } from '../../src' ;
2+ import { MongoCrypt , MongoCryptContext } from '../../src' ;
33import { serialize , Binary , Long } from 'bson' ;
44import * as crypto from 'crypto' ;
55
@@ -21,15 +21,15 @@ describe('MongoCryptConstructor', () => {
2121 const mc = new MongoCrypt ( {
2222 kmsProviders : serialize ( { aws : { } } ) ,
2323 cryptoCallbacks : {
24- aes256CbcEncryptHook : ( ) => { } ,
25- aes256CbcDecryptHook : ( ) => { } ,
26- aes256CtrEncryptHook : ( ) => { } ,
27- aes256CtrDecryptHook : ( ) => { } ,
24+ aes256CbcEncryptHook : ( ) => { } ,
25+ aes256CbcDecryptHook : ( ) => { } ,
26+ aes256CtrEncryptHook : ( ) => { } ,
27+ aes256CtrDecryptHook : ( ) => { } ,
2828 randomHook,
29- hmacSha512Hook : ( ) => { } ,
30- hmacSha256Hook : ( ) => { } ,
31- sha256Hook : ( ) => { } ,
32- signRsaSha256Hook : ( ) => { }
29+ hmacSha512Hook : ( ) => { } ,
30+ hmacSha256Hook : ( ) => { } ,
31+ sha256Hook : ( ) => { } ,
32+ signRsaSha256Hook : ( ) => { }
3333 } ,
3434 errorWrapper : defaultErrorWrapper
3535 } ) ;
@@ -40,17 +40,17 @@ describe('MongoCryptConstructor', () => {
4040 kmsProviders : serialize ( { aws : { } } ) ,
4141 schemaMap : serialize ( { } ) ,
4242 encryptedFieldsMap : serialize ( { } ) ,
43- logger : ( ) => { } ,
43+ logger : ( ) => { } ,
4444 cryptoCallbacks : {
45- aes256CbcEncryptHook : ( ) => { } ,
46- aes256CbcDecryptHook : ( ) => { } ,
47- aes256CtrEncryptHook : ( ) => { } ,
48- aes256CtrDecryptHook : ( ) => { } ,
45+ aes256CbcEncryptHook : ( ) => { } ,
46+ aes256CbcDecryptHook : ( ) => { } ,
47+ aes256CtrEncryptHook : ( ) => { } ,
48+ aes256CtrDecryptHook : ( ) => { } ,
4949 randomHook,
50- hmacSha512Hook : ( ) => { } ,
51- hmacSha256Hook : ( ) => { } ,
52- sha256Hook : ( ) => { } ,
53- signRsaSha256Hook : ( ) => { }
50+ hmacSha512Hook : ( ) => { } ,
51+ hmacSha256Hook : ( ) => { } ,
52+ sha256Hook : ( ) => { } ,
53+ signRsaSha256Hook : ( ) => { }
5454 } ,
5555
5656 bypassQueryAnalysis : false ,
@@ -65,18 +65,24 @@ describe('MongoCryptConstructor', () => {
6565
6666 describe ( 'options.kmsProviders' , ( ) => {
6767 it ( 'throws if provided and are not a Uint8Array' , ( ) => {
68- expect ( ( ) => new MongoCrypt ( {
69- kmsProviders : 3 , errorWrapper : defaultErrorWrapper
70- } ) ) . to . throw (
71- / P a r a m e t e r ` o p t i o n s .k m s P r o v i d e r s ` m u s t b e a U i n t 8 A r r a y ./
72- ) ;
68+ expect (
69+ ( ) =>
70+ new MongoCrypt ( {
71+ kmsProviders : 3 ,
72+ errorWrapper : defaultErrorWrapper
73+ } )
74+ ) . to . throw ( / P a r a m e t e r ` o p t i o n s .k m s P r o v i d e r s ` m u s t b e a U i n t 8 A r r a y ./ ) ;
7375 } ) ;
7476
7577 it ( 'throws when explicitly set to undefined' , ( ) => {
7678 // the error is different because it is thrown from libmongocrypt
77- expect ( ( ) => new MongoCrypt ( {
78- kmsProviders : undefined , errorWrapper : defaultErrorWrapper
79- } ) ) . to . throw ( / n o k m s p r o v i d e r s e t / ) ;
79+ expect (
80+ ( ) =>
81+ new MongoCrypt ( {
82+ kmsProviders : undefined ,
83+ errorWrapper : defaultErrorWrapper
84+ } )
85+ ) . to . throw ( / n o k m s p r o v i d e r s e t / ) ;
8086 } ) ;
8187 } ) ;
8288
@@ -108,7 +114,9 @@ describe('MongoCryptConstructor', () => {
108114 it ( 'does not error' , ( ) => {
109115 expect (
110116 new MongoCrypt ( {
111- kmsProviders : serialize ( { aws : { } } ) , keyExpirationMS : 1000000 , errorWrapper : defaultErrorWrapper
117+ kmsProviders : serialize ( { aws : { } } ) ,
118+ keyExpirationMS : 1000000 ,
119+ errorWrapper : defaultErrorWrapper
112120 } )
113121 ) . to . be . instanceOf ( MongoCrypt ) ;
114122 } ) ;
@@ -118,7 +126,9 @@ describe('MongoCryptConstructor', () => {
118126 it ( 'throws an error' , ( ) => {
119127 expect ( ( ) => {
120128 new MongoCrypt ( {
121- kmsProviders : serialize ( { aws : { } } ) , keyExpirationMS : - 1000000 , errorWrapper : defaultErrorWrapper
129+ kmsProviders : serialize ( { aws : { } } ) ,
130+ keyExpirationMS : - 1000000 ,
131+ errorWrapper : defaultErrorWrapper
122132 } ) ;
123133 } ) . to . throw ( / m u s t b e a n o n - n e g a t i v e n u m b e r / ) ;
124134 } ) ;
@@ -160,7 +170,8 @@ describe('MongoCryptConstructor', () => {
160170
161171 it ( 'has an instance property `status`' , ( ) => {
162172 const mc = new MongoCrypt ( {
163- kmsProviders : serialize ( { aws : { } } ) , errorWrapper : defaultErrorWrapper
173+ kmsProviders : serialize ( { aws : { } } ) ,
174+ errorWrapper : defaultErrorWrapper
164175 } ) ;
165176 expect ( mc ) . to . have . property ( 'status' ) ;
166177 expect ( mc ) . to . have . property ( 'cryptSharedLibVersionInfo' ) ;
@@ -188,9 +199,7 @@ describe('MongoCryptConstructor', () => {
188199 } ) ;
189200
190201 it ( 'returns a MongoCryptContext' , ( ) => {
191- expect ( mc . makeDecryptionContext ( serialize ( { ping : 1 } ) ) ) . to . be . instanceOf (
192- MongoCryptContext
193- ) ;
202+ expect ( mc . makeDecryptionContext ( serialize ( { ping : 1 } ) ) ) . to . be . instanceOf ( MongoCryptContext ) ;
194203 } ) ;
195204 } ) ;
196205
@@ -210,9 +219,7 @@ describe('MongoCryptConstructor', () => {
210219
211220 describe ( '.makeRewrapManyDataKeyContext()' , ( ) => {
212221 it ( 'returns a MongoCryptContext' , ( ) => {
213- expect ( mc . makeRewrapManyDataKeyContext ( serialize ( { } ) ) ) . to . be . instanceOf (
214- MongoCryptContext
215- ) ;
222+ expect ( mc . makeRewrapManyDataKeyContext ( serialize ( { } ) ) ) . to . be . instanceOf ( MongoCryptContext ) ;
216223 } ) ;
217224
218225 describe ( 'when a filter buffer is provided' , ( ) => {
0 commit comments