summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathaniel Kofalt <nathaniel@kofalt.com>2015-06-16 09:58:10 -0500
committerNathaniel Kofalt <nathaniel@kofalt.com>2015-06-16 09:58:10 -0500
commit2e55bbfd56af3c700d4877ffa1665e3ad5cb75a2 (patch)
treea58d55e174313ff05723526010196e824ce41f95
parentaea6ad049b51dcc6f745ae233ff0aacd3a895925 (diff)
downloadjsSHA-2e55bbfd56af3c700d4877ffa1665e3ad5cb75a2.zip
jsSHA-2e55bbfd56af3c700d4877ffa1665e3ad5cb75a2.tar.gz
jsSHA-2e55bbfd56af3c700d4877ffa1665e3ad5cb75a2.tar.bz2
Treat as pseudo unit test if LICENSE file is entered
-rw-r--r--test/hash-file.html29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/hash-file.html b/test/hash-file.html
index 2d30fe0..5b45607 100644
--- a/test/hash-file.html
+++ b/test/hash-file.html
@@ -1,8 +1,23 @@
<script src="../src/sha.js"></script>
<input type="file" id="files" name="file" />
+<p>
<div id="progress"></div>
+<style>
+ .correct
+ {
+ color: #00FF00;
+ background-color: #FFFFFF;
+ }
+
+ .incorrect
+ {
+ color: #FF0000;
+ background-color: #FFFFFF;
+ }
+</style>
+
<script>
// How many bytes to read per chunk
var chunkSize = Math.pow(10, 5)
@@ -47,6 +62,18 @@
if (stop == file.size) {
result = hasher.getHash('HEX')
progress.innerHTML = result
+
+ // Allow testing on project license file
+ if (file.name == 'LICENSE') {
+ progress.innerHTML += ''
+
+ // Compare with sha384sum util
+ if (result == '25490ec88947b64b51e4bd1bcd52e19131c4ae324e4b5d12b17451eaf98121fde440204cb62ed5a1bd44ebff97dec2bd') {
+ progress.innerHTML += '<p>License hash comparison: <span class="correct">PASS</span>'
+ } else {
+ progress.innerHTML += '<p>License hash comparison: <span class="incorrect">FAIL</span>'
+ }
+ }
} else {
readFile(hasher, file, start + chunkSize, stop + chunkSize)
}
@@ -71,5 +98,7 @@
readFile(hasher, file, 0, chunkSize)
}
+ // Trigger file hash
document.getElementById('files').addEventListener('change', handleFileSelect, false)
+
</script>