1
我有一個小測試(摩卡/柴),測試了encryptPass函數返回正確的散列:使用Promise.all與斷言
const assert = require('chai').assert;
const bcrypt = require('bcrypt');
var encryptPass = require('../../shared/helpers/encryptPass.js');
var createUUID = require('../../shared/helpers/createUUID.js');
describe('encryptPass', function() {
it('returns correct password hash',() => {
var pass = createUUID();
var encryptedPass = encryptPass(pass);
Promise.all([pass, encryptedPass]).then(values => {
let [pass, encryptedPass] = values;
var compareResult = bcrypt.compareSync(pass, encryptedPass);
assert.equal(compareResult, true);
});
});
});
我擔心的是,有是斷言是假設Promise.all函數將工作而不會拋出錯誤。如何最好地處理這個問題?