This commit is contained in:
2020-03-04 13:21:54 +01:00
parent 8de034af69
commit 1e2e853fc0
3 changed files with 32 additions and 9 deletions

21
test/index.js Normal file
View File

@ -0,0 +1,21 @@
'use strict';
const helper = require ('../index');
const test = require ('ava');
test ('create hash', async (t) => {
const hash = await helper.hash ('foo');
t.is (typeof hash, 'string');
});
test ('validate', async (t) => {
const hash = await helper.hash ('foo');
const valid = await helper.verify (hash, 'foo');
t.is (valid, true);
});
test ('fail validation', async (t) => {
const hash = await helper.hash ('foo');
const valid = await helper.verify (hash, 'bar');
t.is (valid, false);
});