Skip to content

Commit 796af98

Browse files
authored
test: Condition tests for web-crypto-backend (#171)
1 parent 6d32c7a commit 796af98

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

modules/web-crypto-backend/test/backend-factory.test.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ import * as chai from 'chai'
1919
import chaiAsPromised from 'chai-as-promised'
2020
import sinon from 'sinon'
2121
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'
2329
import * as browserWindow from '@aws-sdk/util-locate-window'
2430

2531
import * as fixtures from './fixtures'
@@ -189,3 +195,25 @@ describe('webCryptoBackendFactory', () => {
189195
})
190196
})
191197
})
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

Comments
 (0)