mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
fix: Allow quad data for containers
This prevents the container data check from throwing an error when converting to quads if the incoming data already is quads.
This commit is contained in:
@@ -17,6 +17,8 @@ import * as quadUtil from '../../../src/util/QuadUtil';
|
||||
import { guardedStreamFrom } from '../../../src/util/StreamUtil';
|
||||
import { CONTENT_TYPE, HTTP, LDP, RDF } from '../../../src/util/UriConstants';
|
||||
import { toNamedNode } from '../../../src/util/UriUtil';
|
||||
import quad = DataFactory.quad;
|
||||
import namedNode = DataFactory.namedNode;
|
||||
|
||||
class SimpleDataAccessor implements DataAccessor {
|
||||
public readonly data: Record<string, Representation> = {};
|
||||
@@ -295,6 +297,20 @@ describe('A DataAccessorBasedStore', (): void => {
|
||||
expect(accessor.data[resourceID.path].metadata.contentType).toBeUndefined();
|
||||
});
|
||||
|
||||
it('can write containers with quad data.', async(): Promise<void> => {
|
||||
const resourceID = { path: `${root}container/` };
|
||||
|
||||
// Generate based on URI
|
||||
representation.metadata.removeAll(RDF.type);
|
||||
representation.metadata.contentType = 'internal/quads';
|
||||
representation.data = guardedStreamFrom(
|
||||
[ quad(namedNode(`${root}resource/`), namedNode('a'), namedNode('coolContainer')) ],
|
||||
);
|
||||
await expect(store.setRepresentation(resourceID, representation)).resolves.toBeUndefined();
|
||||
expect(accessor.data[resourceID.path]).toBeTruthy();
|
||||
expect(accessor.data[resourceID.path].metadata.contentType).toBeUndefined();
|
||||
});
|
||||
|
||||
it('errors when trying to create a container with containment triples.', async(): Promise<void> => {
|
||||
const resourceID = { path: `${root}container/` };
|
||||
representation.metadata.add(RDF.type, toNamedNode(LDP.Container));
|
||||
|
||||
Reference in New Issue
Block a user