Hemmelig.app/tests/server/helpers/password.test.js
bjarneo 0c86efd56c
refactor: use fastify vite for the dev server (#284)
* refactor: use fastify vite for the server

by doing this we do not need to have local hacks for the routes. No local proxy needed. Everything just works.

* fix: update the dockerfile build path

* fix: update package.json

* fix: fonts path
2024-03-11 13:43:20 +01:00

24 lines
831 B
JavaScript

import assert from 'assert';
import { compare, hash } from '../../../server/helpers/password.js';
const PASSWORD = 'suP3rL0ng!PssWrd';
describe('Password', () => {
describe('#hash(password), #compare(password, hash)', () => {
it('should hash as password, then compare it to be true', async () => {
const hashedPassword = await hash(PASSWORD);
assert.equal(typeof hashedPassword, 'string');
assert.equal(await compare(PASSWORD, hashedPassword), true);
});
it('should hash as password, then compare it to be false', async () => {
const hashedPassword = await hash(PASSWORD);
assert.equal(typeof hashedPassword, 'string');
assert.equal(await compare(PASSWORD + 'wrong_password', hashedPassword), false);
});
});
});