Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
bachelor 2022
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mikkel Aas
bachelor 2022
Commits
21f7b104
Commit
21f7b104
authored
Apr 28, 2022
by
Mikkel Aas
Browse files
Options
Downloads
Patches
Plain Diff
put file paths into constants
parent
e3e3752d
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
__tests__/fileHash.test.ts
+11
-6
11 additions, 6 deletions
__tests__/fileHash.test.ts
with
11 additions
and
6 deletions
__tests__/fileHash.test.ts
+
11
−
6
View file @
21f7b104
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
);
});
});
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment