Skip to content

Commit

Permalink
Added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mehmeteminkartal committed Apr 23, 2024
1 parent e377d31 commit 4e7206b
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/TimeStampRequest.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,28 @@ describe('TimeStampRequest Tests', () => {
}).toString();
expect(out).toBe(snapshotOut);
});

it('should generate random values', () => {
// Arrange
const hashAlgorithm = 'SHA-256';
const hashValue = new Uint8Array([1, 2, 3, 4, 5]);
const request = new TimeStampRequest(hashAlgorithm, hashValue);

// Act
const nonce = new Uint8Array(8);
request.getRandomValues(nonce);

// Assert
expect(nonce).toBeDefined();

// make sure the nonce is not all zeros
let allZeros = true;
for (let i = 0; i < nonce.length; i++) {
if (nonce[i] !== 0) {
allZeros = false;
break;
}
}
expect(allZeros).toBe(false);
});
});

0 comments on commit 4e7206b

Please sign in to comment.