mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
feat: Only accept NamedNodes as predicates for metadata
* refactor: move toCachedNamedNode (private) * chore: only NamedNodes predicates in removes * feat: enforce NamedNode predicates in most cases * feat: getAll only accepts NamedNodes * feat: toCachedNamedNode only accepts string arg * tests: use NamedNodes for getAll calls * test: remove unnecessary string check for coverage * tests: fix NamedNodes in new tests after rebase * feat: metadatawriters store NamedNodes * refactor: toCachedNamedNode as utility function * fix: double write of linkRelMap * test: use the CONTENT_TYPE constant
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { DataFactory } from 'n3';
|
||||
import type { ResourceIdentifier } from '../../../../src/http/representation/ResourceIdentifier';
|
||||
import { TemplatedResourcesGenerator } from '../../../../src/pods/generate/TemplatedResourcesGenerator';
|
||||
import type {
|
||||
@@ -10,6 +11,8 @@ import { readableToString } from '../../../../src/util/StreamUtil';
|
||||
import { HandlebarsTemplateEngine } from '../../../../src/util/templates/HandlebarsTemplateEngine';
|
||||
import { mockFs } from '../../../util/Util';
|
||||
|
||||
const { namedNode } = DataFactory;
|
||||
|
||||
jest.mock('fs');
|
||||
|
||||
class DummyFactory implements FileIdentifierMapperFactory {
|
||||
@@ -115,7 +118,7 @@ describe('A TemplatedResourcesGenerator', (): void => {
|
||||
const rootMetadata = result[0].representation.metadata;
|
||||
expect(rootMetadata.identifier.value).toBe(location.path);
|
||||
expect(rootMetadata.quads()).toHaveLength(2);
|
||||
expect(rootMetadata.get('pre:has')?.value).toBe('metadata');
|
||||
expect(rootMetadata.get(namedNode('pre:has'))?.value).toBe('metadata');
|
||||
expect(rootMetadata.contentType).toBe('text/turtle');
|
||||
|
||||
// Container has no metadata triples besides content-type
|
||||
@@ -128,7 +131,7 @@ describe('A TemplatedResourcesGenerator', (): void => {
|
||||
const docMetadata = result[2].representation.metadata;
|
||||
expect(docMetadata.identifier.value).toBe(`${location.path}container/template`);
|
||||
expect(docMetadata.quads()).toHaveLength(2);
|
||||
expect(docMetadata.get('pre:has')?.value).toBe('metadata');
|
||||
expect(docMetadata.get(namedNode('pre:has'))?.value).toBe('metadata');
|
||||
expect(docMetadata.contentType).toBe('text/turtle');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user