import {hash, verify} from '../source/authentication/passwordAuthentication.js';
import {notStrictEqual, strictEqual} from 'assert';

describe('Password authentication', () => {
    const password = '123';
    let storedPassword;

    before(async () => storedPassword = await hash(password));

    it('validates a correct password', async () => {
        strictEqual(await verify(password, storedPassword), true);
    });

    it(`doesn't validate a wrong password`, async () => {
        strictEqual(await verify('456', storedPassword), false);
    });

    it(`hashes the same password differently`, async () => {
        notStrictEqual(storedPassword, await hash(password));
    });
});