using done() instead of promise, to enforce mocha to wait on the tests

This commit is contained in:
El RIDO 2018-09-02 11:52:57 +02:00
parent 176264f135
commit f3eaee206c
No known key found for this signature in database
GPG Key ID: 0F5C940A6BD81F92
1 changed files with 8 additions and 6 deletions

View File

@ -31,14 +31,14 @@ describe('CryptTool', function () {
// SJCL based pastes still works // SJCL based pastes still works
it( it(
'supports PrivateBin v1 ciphertext (SJCL & browser atob)', 'supports PrivateBin v1 ciphertext (SJCL & browser atob)',
function () { function (done) {
delete global.Base64; delete global.Base64;
var clean = jsdom(); var clean = jsdom();
window.crypto = new WebCrypto(); window.crypto = new WebCrypto();
// Of course you can easily decipher the following texts, if you like. // Of course you can easily decipher the following texts, if you like.
// Bonus points for finding their sources and hidden meanings. // Bonus points for finding their sources and hidden meanings.
return $.PrivateBin.CryptTool.decipher( $.PrivateBin.CryptTool.decipher(
'6t2qsmLyfXIokNCL+3/yl15rfTUBQvm5SOnFPvNE7Q8=', '6t2qsmLyfXIokNCL+3/yl15rfTUBQvm5SOnFPvNE7Q8=',
// -- "That's amazing. I've got the same combination on my luggage." // -- "That's amazing. I've got the same combination on my luggage."
Array.apply(0, Array(6)).map(function(_,b) { return b + 1; }).join(''), Array.apply(0, Array(6)).map(function(_,b) { return b + 1; }).join(''),
@ -70,7 +70,7 @@ describe('CryptTool', function () {
'C5fARPJ4F2BIWgzgzkNj+dVjusft2XnziamWdbS5u3kuRlVuz5LQj+R5' + 'C5fARPJ4F2BIWgzgzkNj+dVjusft2XnziamWdbS5u3kuRlVuz5LQj+R5' +
'imnqQAincdZTkTT1nYx+DatlOLllCYIHffpI="}' 'imnqQAincdZTkTT1nYx+DatlOLllCYIHffpI="}'
).then(function(paste1) { ).then(function(paste1) {
return $.PrivateBin.CryptTool.decipher( $.PrivateBin.CryptTool.decipher(
's9pmKZKOBN7EVvHpTA8jjLFH3Xlz/0l8lB4+ONPACrM=', 's9pmKZKOBN7EVvHpTA8jjLFH3Xlz/0l8lB4+ONPACrM=',
'', // no password '', // no password
'{"iv":"WA42mdxIVXUwBqZu7JYNiw==","v":1,"iter":10000,"ks"' + '{"iv":"WA42mdxIVXUwBqZu7JYNiw==","v":1,"iter":10000,"ks"' +
@ -101,6 +101,7 @@ describe('CryptTool', function () {
paste1.includes('securely packed in iron') && paste1.includes('securely packed in iron') &&
paste2.includes('Sol is right') paste2.includes('Sol is right')
); );
done();
}); });
}); });
} }
@ -108,14 +109,14 @@ describe('CryptTool', function () {
it( it(
'supports ZeroBin ciphertext (SJCL & Base64 1.7)', 'supports ZeroBin ciphertext (SJCL & Base64 1.7)',
function () { function (done) {
global.Base64 = require('../base64-1.7').Base64; global.Base64 = require('../base64-1.7').Base64;
var clean = jsdom(); var clean = jsdom();
window.crypto = new WebCrypto(); window.crypto = new WebCrypto();
// Of course you can easily decipher the following texts, if you like. // Of course you can easily decipher the following texts, if you like.
// Bonus points for finding their sources and hidden meanings. // Bonus points for finding their sources and hidden meanings.
return $.PrivateBin.CryptTool.decipher( $.PrivateBin.CryptTool.decipher(
'6t2qsmLyfXIokNCL+3/yl15rfTUBQvm5SOnFPvNE7Q8=', '6t2qsmLyfXIokNCL+3/yl15rfTUBQvm5SOnFPvNE7Q8=',
// -- "That's amazing. I've got the same combination on my luggage." // -- "That's amazing. I've got the same combination on my luggage."
Array.apply(0, Array(6)).map(function(_,b) { return b + 1; }).join(''), Array.apply(0, Array(6)).map(function(_,b) { return b + 1; }).join(''),
@ -139,7 +140,7 @@ describe('CryptTool', function () {
'V37AeiNoD2PcI6ZcHbRdPa+XRrRcJhSPPW7UQ0z4OvBfjdu/w390QxAx' + 'V37AeiNoD2PcI6ZcHbRdPa+XRrRcJhSPPW7UQ0z4OvBfjdu/w390QxAx' +
'SxvZewoh49fKKB6hTsRnZb4tpHkjlww=="}' 'SxvZewoh49fKKB6hTsRnZb4tpHkjlww=="}'
).then(function(paste1) { ).then(function(paste1) {
return $.PrivateBin.CryptTool.decipher( $.PrivateBin.CryptTool.decipher(
's9pmKZKOBN7EVvHpTA8jjLFH3Xlz/0l8lB4+ONPACrM=', 's9pmKZKOBN7EVvHpTA8jjLFH3Xlz/0l8lB4+ONPACrM=',
'', // no password '', // no password
'{"iv":"Z7lAZQbkrqGMvruxoSm6Pw==","v":1,"iter":10000,"ks"' + '{"iv":"Z7lAZQbkrqGMvruxoSm6Pw==","v":1,"iter":10000,"ks"' +
@ -164,6 +165,7 @@ describe('CryptTool', function () {
paste1.includes('securely packed in iron') && paste1.includes('securely packed in iron') &&
paste2.includes('Sol is right') paste2.includes('Sol is right')
); );
done();
}); });
}); });
} }