mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
refactor: Rename UriUtil functions
Forgot to do this when rebasing
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { literal, namedNode } from '@rdfjs/data-model';
|
||||
import { CONTENT_TYPE, XSD } from '../../../src/util/UriConstants';
|
||||
import { getNamedNode, getObjectTerm, getTypedLiteral, isTerm } from '../../../src/util/UriUtil';
|
||||
import { toNamedNode, toObjectTerm, toTypedLiteral, isTerm } from '../../../src/util/UriUtil';
|
||||
|
||||
describe('An UriUtil', (): void => {
|
||||
describe('isTerm function', (): void => {
|
||||
@@ -16,21 +16,21 @@ describe('An UriUtil', (): void => {
|
||||
describe('getNamedNode function', (): void => {
|
||||
it('returns the input if it was a named node.', async(): Promise<void> => {
|
||||
const term = namedNode('name');
|
||||
expect(getNamedNode(term)).toBe(term);
|
||||
expect(toNamedNode(term)).toBe(term);
|
||||
});
|
||||
|
||||
it('returns a named node when a string is used.', async(): Promise<void> => {
|
||||
expect(getNamedNode('name')).toEqualRdfTerm(namedNode('name'));
|
||||
expect(toNamedNode('name')).toEqualRdfTerm(namedNode('name'));
|
||||
});
|
||||
|
||||
it('caches generated named nodes.', async(): Promise<void> => {
|
||||
const result = getNamedNode('name');
|
||||
const result = toNamedNode('name');
|
||||
expect(result).toEqualRdfTerm(namedNode('name'));
|
||||
expect(getNamedNode('name')).toBe(result);
|
||||
expect(toNamedNode('name')).toBe(result);
|
||||
});
|
||||
|
||||
it('supports URI shorthands.', async(): Promise<void> => {
|
||||
expect(getNamedNode('contentType')).toEqualRdfTerm(namedNode(CONTENT_TYPE));
|
||||
expect(toNamedNode('contentType')).toEqualRdfTerm(namedNode(CONTENT_TYPE));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -38,19 +38,19 @@ describe('An UriUtil', (): void => {
|
||||
it('returns the input if it was a term.', async(): Promise<void> => {
|
||||
const nn = namedNode('name');
|
||||
const lit = literal('lit');
|
||||
expect(getObjectTerm(nn)).toBe(nn);
|
||||
expect(getObjectTerm(lit)).toBe(lit);
|
||||
expect(toObjectTerm(nn)).toBe(nn);
|
||||
expect(toObjectTerm(lit)).toBe(lit);
|
||||
});
|
||||
|
||||
it('returns a literal when a string is used.', async(): Promise<void> => {
|
||||
expect(getObjectTerm('lit')).toEqualRdfTerm(literal('lit'));
|
||||
expect(toObjectTerm('lit')).toEqualRdfTerm(literal('lit'));
|
||||
});
|
||||
});
|
||||
|
||||
describe('getTypedLiteral function', (): void => {
|
||||
it('converts the input to a valid literal with the given type.', async(): Promise<void> => {
|
||||
const expected = literal('5', namedNode(XSD.integer));
|
||||
expect(getTypedLiteral(5, XSD.integer)).toEqualRdfTerm(expected);
|
||||
expect(toTypedLiteral(5, XSD.integer)).toEqualRdfTerm(expected);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user