@@ -19,7 +19,13 @@ import * as chai from 'chai'
19
19
import chaiAsPromised from 'chai-as-promised'
20
20
import sinon from 'sinon'
21
21
import 'mocha'
22
- import { pluckSubtleCrypto , windowRequiresFallback , webCryptoBackendFactory } from '../src/backend-factory'
22
+ import {
23
+ pluckSubtleCrypto ,
24
+ windowRequiresFallback ,
25
+ webCryptoBackendFactory ,
26
+ getNonZeroByteBackend ,
27
+ getZeroByteSubtle
28
+ } from '../src/backend-factory'
23
29
import * as browserWindow from '@aws-sdk/util-locate-window'
24
30
25
31
import * as fixtures from './fixtures'
@@ -189,3 +195,25 @@ describe('webCryptoBackendFactory', () => {
189
195
} )
190
196
} )
191
197
} )
198
+
199
+ describe ( 'getNonZeroByteBackend' , ( ) => {
200
+ it ( 'gets a subtle backend' , ( ) => {
201
+ const test = getNonZeroByteBackend ( fixtures . subtleFallbackSupportsZeroByteGCM )
202
+ expect ( test === fixtures . subtleFallbackSupportsZeroByteGCM . subtle ) . to . equal ( true )
203
+ } )
204
+
205
+ it ( 'Precondition: A backend must be passed to get a non zero byte backend.' , ( ) => {
206
+ expect ( ( ) => getNonZeroByteBackend ( false ) ) . to . throw ( 'No supported backend.' )
207
+ } )
208
+ } )
209
+
210
+ describe ( 'getZeroByteSubtle' , ( ) => {
211
+ it ( 'gets a subtle backend' , ( ) => {
212
+ const test = getZeroByteSubtle ( fixtures . subtleFallbackSupportsZeroByteGCM )
213
+ expect ( test === fixtures . subtleFallbackSupportsZeroByteGCM . subtle ) . to . equal ( true )
214
+ } )
215
+
216
+ it ( 'Precondition: A backend must be passed to get a zero byte backend.' , ( ) => {
217
+ expect ( ( ) => getZeroByteSubtle ( false ) ) . to . throw ( 'No supported backend.' )
218
+ } )
219
+ } )
0 commit comments