Skip to content

Commit f886c83

Browse files
authored
test: Condition tests for caching-materials-manager-browser (#177)
1 parent 696de23 commit f886c83

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

modules/caching-materials-manager-browser/test/caching_materials_manager_browser.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,27 @@ describe('WebCryptoCachingMaterialsManager', () => {
5959
expect(test._maxBytesEncrypted).to.equal(maxBytesEncrypted)
6060
expect(test._maxMessagesEncrypted).to.equal(maxMessagesEncrypted)
6161
})
62+
63+
it('Precondition: A partition value must exist for WebCryptoCachingMaterialsManager.', () => {
64+
class TestKeyring extends KeyringWebCrypto {
65+
async _onEncrypt (): Promise<WebCryptoEncryptionMaterial> {
66+
throw new Error('never')
67+
}
68+
async _onDecrypt (): Promise<WebCryptoDecryptionMaterial> {
69+
throw new Error('never')
70+
}
71+
}
72+
73+
const keyring = new TestKeyring()
74+
const cache = 'cache' as any
75+
const maxAge = 10
76+
const test = new WebCryptoCachingMaterialsManager({
77+
backingMaterials: keyring,
78+
cache,
79+
maxAge
80+
})
81+
/* 64 Bytes of data encoded as base64 will be 88 characters long.
82+
*/
83+
expect(test._partition).to.be.a('string').and.to.have.lengthOf(88)
84+
})
6285
})

0 commit comments

Comments
 (0)