Skip to content
Snippets Groups Projects
Commit 21f7b104 authored by Mikkel Aas's avatar Mikkel Aas
Browse files

put file paths into constants

parent e3e3752d
Branches
No related tags found
No related merge requests found
import assert from 'assert';
import {hashFile, isHashValid} from '../src/utils/fileHasher';
const PATH_TO_TEST_CONTRACT_0 = '__tests__/test data/test-arbeidskontrakt-00.pdf';
const PATH_TO_TEST_CONTRACT_1 = '__tests__/test data/test-arbeidskontrakt-01.pdf';
const TEST_CONTRACT_0_HASH = 'a21888557401c7e6e8fc12123e48fe11597084b67a7127dd7844a32006210d9d';
describe('the file hash script', function (){
describe('the hash file function', function() {
it('should create a hash of a file', function () {
const fileHash = hashFile('test/test data/test-arbeidskontrakt-00.pdf');
const expectedHash = 'a21888557401c7e6e8fc12123e48fe11597084b67a7127dd7844a32006210d9d';
const fileHash = hashFile(PATH_TO_TEST_CONTRACT_0);
const expectedHash = TEST_CONTRACT_0_HASH;
assert.equal(fileHash, expectedHash);
});
......@@ -16,13 +21,13 @@ describe('the file hash script', function (){
});
describe('the isHashValid function', function (){
it('should return true if the same file is hashed twice', function () {
const fileHash1 = hashFile('test/test data/test-arbeidskontrakt-00.pdf');
const isEqual = isHashValid(fileHash1, 'test/test data/test-arbeidskontrakt-00.pdf');
const fileHash1 = hashFile(PATH_TO_TEST_CONTRACT_0);
const isEqual = isHashValid(fileHash1, PATH_TO_TEST_CONTRACT_0);
assert.equal(isEqual, true);
});
it('should return false if two different files are hashed', function () {
const fileHash1 = hashFile('test/test data/test-arbeidskontrakt-00.pdf');
const isEqual = isHashValid(fileHash1, 'test/test data/test-arbeidskontrakt-01.pdf');
const fileHash1 = hashFile(PATH_TO_TEST_CONTRACT_0);
const isEqual = isHashValid(fileHash1, PATH_TO_TEST_CONTRACT_1);
assert.equal(isEqual, false);
});
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment