blob: f5cdea8351242c16b210f9be0795521c416f66d2 (
plain) (
blame)
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
|
var encryptor = require('../../../app/scripts/lib/encryptor')
QUnit.test('encryptor', function(assert) {
var done = assert.async();
var password, data, encrypted
password = 'a sample passw0rd'
data = { foo: 'data to encrypt' }
encryptor.encrypt(password, data)
.then(function(encryptedStr) {
assert.equal(typeof encryptedStr, 'string', 'returns a string')
// Now try decrypting!jk
//
return encryptor.decrypt(password, encryptedStr)
})
.then(function (decryptedObj) {
assert.equal(decryptedObj, data, 'decrypted what was encrypted')
done()
})
.catch(function(reason) {
assert.ifError(reason, 'threw an error')
})
})
|