File size: 867 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// @flow
import {
  encryptString,
  decryptString,
  encryptObject,
  decryptObject,
} from '../encryption';

const inputString = 'this should be encrypted';
const inputObject = { foo: 'bar', biz: 'baz' };

it('should encrypt and decrypt a string', () => {
  const encrypted = encryptString(inputString);
  const decrypted = decryptString(encrypted);

  expect(encrypted).not.toEqual(inputString);
  expect(decrypted).toEqual(inputString);
  expect(typeof decrypted).toEqual('string');
  expect(typeof encrypted).toEqual('string');
});

it('should encrypt and decrypt a object', () => {
  const encrypted = encryptObject(inputObject);
  const decrypted = decryptObject(encrypted);

  expect(encrypted).not.toEqual(inputObject);
  expect(decrypted).toEqual(inputObject);
  expect(typeof decrypted).toEqual('object');
  expect(typeof encrypted).toEqual('string');
});