1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-24 02:58:09 +01:00
metamask-extension/test/integration/lib/encryptor-test.js

29 lines
673 B
JavaScript
Raw Normal View History

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')
})
})