CommunitySolidServer/test/unit/storage/Conditions.test.ts
2021-08-18 13:16:08 +02:00

18 lines
724 B
TypeScript

import { RepresentationMetadata } from '../../../src/ldp/representation/RepresentationMetadata';
import { getETag } from '../../../src/storage/Conditions';
import { DC } from '../../../src/util/Vocabularies';
describe('Conditions', (): void => {
describe('#getETag', (): void => {
it('creates an ETag based on the date last modified.', async(): Promise<void> => {
const now = new Date();
const metadata = new RepresentationMetadata({ [DC.modified]: now.toISOString() });
expect(getETag(metadata)).toBe(`"${now.getTime()}"`);
});
it('returns undefined if no date was found.', async(): Promise<void> => {
expect(getETag(new RepresentationMetadata())).toBeUndefined();
});
});
});