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:
@@ -22,14 +22,14 @@ describe('A LinkParser', (): void => {
|
||||
request.headers.link = '<http://test.com/type>;rel="type"';
|
||||
await expect(parser.handle({ request, metadata })).resolves.toBeUndefined();
|
||||
expect(metadata.quads()).toHaveLength(1);
|
||||
expect(metadata.get(RDF.type)?.value).toBe('http://test.com/type');
|
||||
expect(metadata.get(RDF.terms.type)?.value).toBe('http://test.com/type');
|
||||
});
|
||||
|
||||
it('supports multiple link headers.', async(): Promise<void> => {
|
||||
request.headers.link = [ '<http://test.com/typeA>;rel="type"', '<http://test.com/typeB>;rel=type' ];
|
||||
await expect(parser.handle({ request, metadata })).resolves.toBeUndefined();
|
||||
expect(metadata.quads()).toHaveLength(2);
|
||||
expect(metadata.getAll(RDF.type).map((term): any => term.value))
|
||||
expect(metadata.getAll(RDF.terms.type).map((term): any => term.value))
|
||||
.toEqual([ 'http://test.com/typeA', 'http://test.com/typeB' ]);
|
||||
});
|
||||
|
||||
@@ -37,7 +37,7 @@ describe('A LinkParser', (): void => {
|
||||
request.headers.link = '<http://test.com/typeA>;rel="type" , <http://test.com/typeB>;rel=type';
|
||||
await expect(parser.handle({ request, metadata })).resolves.toBeUndefined();
|
||||
expect(metadata.quads()).toHaveLength(2);
|
||||
expect(metadata.getAll(RDF.type).map((term): any => term.value))
|
||||
expect(metadata.getAll(RDF.terms.type).map((term): any => term.value))
|
||||
.toEqual([ 'http://test.com/typeA', 'http://test.com/typeB' ]);
|
||||
});
|
||||
|
||||
|
||||
@@ -30,6 +30,6 @@ describe('A SlugParser', (): void => {
|
||||
request.headers.slug = 'slugA';
|
||||
await expect(parser.handle({ request, metadata })).resolves.toBeUndefined();
|
||||
expect(metadata.quads()).toHaveLength(1);
|
||||
expect(metadata.get(SOLID_HTTP.slug)?.value).toBe('slugA');
|
||||
expect(metadata.get(SOLID_HTTP.terms.slug)?.value).toBe('slugA');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user