- TypeScript definitions.
- clone method.

Changed
- throw error if update after finalize
This commit is contained in:
Yi-Cyuan Chen
2018-08-05 17:09:04 +08:00
parent 241405d4fd
commit b6c443143f
11 changed files with 411 additions and 125 deletions
+20 -1
View File
@@ -203,9 +203,18 @@
call: function (key, message) {
var hash = algorithm.update(key, message);
hash.hex();
hash.update(message);
hash.finalize();
return hash.hex();
}
},
{
name: 'clone',
call: function (key, message) {
var hash = algorithm.update(key, message);
var hash2 = hash.clone();
hash.update('any');
return hash2.hex();
}
}
];
@@ -250,6 +259,16 @@
});
});
context('when update after finalize', function () {
it('should throw error', function () {
expect(function () {
var hash = algorithm.update('key', 'any');
hash.hex();
hash.update('any');
}).to.throwError(/finalize already called/);
});
});
describe('#' + name, function () {
errorTestCases.forEach(function (testCase) {
context('when ' + testCase, function () {
+20 -1
View File
@@ -260,9 +260,18 @@
call: function (message) {
var hash = algorithm.update(message);
hash.hex();
hash.update(message);
hash.finalize();
return hash.hex();
}
},
{
name: 'clone',
call: function (message) {
var hash = algorithm.update(message);
var hash2 = hash.clone();
hash.update('any');
return hash2.hex();
}
}
];
@@ -317,6 +326,16 @@
});
});
context('when update after finalize', function () {
it('should throw error', function () {
expect(function () {
var hash = algorithm.update('any');
hash.hex();
hash.update('any');
}).to.throwError(/finalize already called/);
});
});
context('when large size', function () {
var hash = algorithm.create();
hash.bytes = 4294967295;