1 import { LinksKeys } from './useLinksKeys';
3 describe('useLinksKeys', () => {
7 keys = new LinksKeys();
10 it('returns empty passphrase when not set', () => {
11 keys.setPassphrase('shareId', 'linkId', 'pass');
12 expect(keys.getPassphrase('shareId', 'missingLinkId')).toBe(undefined);
15 it('returns the cached passphrase', () => {
16 keys.setPassphrase('shareId', 'linkId', 'pass');
17 expect(keys.getPassphrase('shareId', 'linkId')).toBe('pass');
20 it('setting another key for the same link does not remove the other key', () => {
21 const hashKey = new Uint8Array([1, 2]);
22 keys.setPassphrase('shareId', 'linkId', 'pass');
23 keys.setHashKey('shareId', 'linkId', hashKey);
24 expect(keys.getPassphrase('shareId', 'linkId')).toBe('pass');
25 expect(keys.getHashKey('shareId', 'linkId')).toBe(hashKey);
28 it('setting the key again overrides the original value', () => {
29 keys.setPassphrase('shareId', 'linkId', 'pass');
30 keys.setPassphrase('shareId', 'linkId', 'newpass');
31 expect(keys.getPassphrase('shareId', 'linkId')).toBe('newpass');