22 lines
511 B
JavaScript
22 lines
511 B
JavaScript
'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);
|
|
});
|