jsonld-signatures-merkleproof2019
Version:
A jsonld signature implementation to support MerkleProof2019 verification in Verifiable Credential context
29 lines (25 loc) • 1.04 kB
text/typescript
import { describe, it, expect } from 'vitest';
import { dateToUnixTimestamp, timestampToDateObject } from '../../src/utils/date';
describe('dateToUnixTimestamp method', function () {
describe('when given an empty string', function () {
it('should return an empty string', function () {
const emptyString = '';
const result = dateToUnixTimestamp(emptyString);
expect(result).toBe(emptyString);
});
});
describe('when given an iso date', function () {
it('should return a valid date', function () {
const isoDate = '2018-06-18T22:37:22.325+00:00';
const result = dateToUnixTimestamp(isoDate);
expect(result).toEqual(new Date('2018-06-18T22:37:22.325Z'));
});
});
});
describe('timestampToDateObject method', function () {
it('should return a date object from a timestamp', function () {
const fixtureTimestamp = 1518049414;
const assertionDateObject = new Date(1518049414 * 1000);
expect(timestampToDateObject(fixtureTimestamp)).toEqual(assertionDateObject);
});
});