aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorCsaba Solya <csaba.solya@gmail.com>2018-02-23 17:49:56 +0800
committerCsaba Solya <csaba.solya@gmail.com>2018-02-23 17:49:56 +0800
commitcd05d77c3fd9fe8e49d38b43728ff90b72b1ca9d (patch)
tree5ce706b0245ccf4024f07af76e65438b30b5adfd /test
parent73d9bfc52cfb4b63f0960d80a7b68f2bf6f7d88c (diff)
downloadtangerine-wallet-browser-cd05d77c3fd9fe8e49d38b43728ff90b72b1ca9d.tar.gz
tangerine-wallet-browser-cd05d77c3fd9fe8e49d38b43728ff90b72b1ca9d.tar.zst
tangerine-wallet-browser-cd05d77c3fd9fe8e49d38b43728ff90b72b1ca9d.zip
fix tests
Diffstat (limited to 'test')
-rw-r--r--test/unit/edge-encryptor-test.js26
1 files changed, 20 insertions, 6 deletions
diff --git a/test/unit/edge-encryptor-test.js b/test/unit/edge-encryptor-test.js
index 627386051..ef733a494 100644
--- a/test/unit/edge-encryptor-test.js
+++ b/test/unit/edge-encryptor-test.js
@@ -5,21 +5,21 @@ const EdgeEncryptor = require('../../app/scripts/edge-encryptor')
var password = 'passw0rd1'
var data = 'some random data'
-// polyfill fetch
global.crypto = global.crypto || {
- getRandomValues (array) {
+ getRandomValues: function (array) {
for (let i = 0; i < array.length; i++) {
- array[i] = Math.random() * 100;
+ array[i] = Math.random() * 100
}
+ return array
}
}
describe('EdgeEncryptor', function () {
- const edgeEncryptor = new EdgeEncryptor()
+ const edgeEncryptor = new EdgeEncryptor()
describe('encrypt', function () {
- it('should encrypt the data.', function () {
+ it('should encrypt the data.', function (done) {
edgeEncryptor.encrypt(password, data)
.then(function (encryptedData) {
assert.notEqual(data, encryptedData)
@@ -30,6 +30,19 @@ describe('EdgeEncryptor', function () {
})
})
+ it('should return proper format.', function (done) {
+ edgeEncryptor.encrypt(password, data)
+ .then(function (encryptedData) {
+ let encryptedObject = JSON.parse(encryptedData)
+ assert.ok(encryptedObject.data, 'there is no data')
+ assert.ok(encryptedObject.iv && encryptedObject.iv.length != 0, 'there is no iv')
+ assert.ok(encryptedObject.salt && encryptedObject.salt.length != 0, 'there is no salt')
+ done()
+ }).catch(function (err) {
+ done(err)
+ })
+ })
+
it('should not return the same twice.', function () {
const encryptPromises = []
@@ -46,13 +59,14 @@ describe('EdgeEncryptor', function () {
})
describe('decrypt', function () {
- it('should be able to decrypt the encrypted data.', function () {
+ it('should be able to decrypt the encrypted data.', function (done) {
edgeEncryptor.encrypt(password, data)
.then(function (encryptedData) {
edgeEncryptor.decrypt(password, encryptedData)
.then(function (decryptedData) {
assert.equal(decryptedData, data)
+ done()
})
.catch(function (err) {
done(err)