UNPKG

741 BJavaScriptView Raw
1const assert = require('assert')
2
3const {
4 SHA1,
5 checksum,
6 checksumFilePath,
7 hashFromFileContent,
8} = require('./checksum')
9
10// NOTE: Using `echo -n <string> | sha1sum` to generate expected result
11assert(checksum('', SHA1) === 'da39a3ee5e6b4b0d3255bfef95601890afd80709')
12assert(checksum('42', SHA1) === '92cfceb39d57d914ed8b14d0e37643de0797ae56')
13assert(checksum('abc', SHA1) === 'a9993e364706816aba3e25717850c26c9cd0d89d')
14
15assert(hashFromFileContent('1234 x.txt') === '1234')
16assert(hashFromFileContent(' 1234 x.txt ') === '1234')
17
18assert(checksumFilePath('./test.txt') === '.test.txt.sha')
19assert(checksumFilePath('../test.txt') === '../.test.txt.sha')
20
21// TODO:
22// assert(checksumFilePath('.test.txt') === '.test.txt.sha')