Skip to content

Commit 7f7d2b4

Browse files
authored
Merge pull request #16 from rdfjs-base/rdf-ns
fix: removed whitespace from rdf ns definition, added tests for utils
2 parents 1447d79 + 3ba2955 commit 7f7d2b4

File tree

3 files changed

+89
-1
lines changed

3 files changed

+89
-1
lines changed

lib/namespaces.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import namespace from '@rdfjs/namespace'
22

3-
const rdf = namespace(' http://www.w3.org/1999/02/22-rdf-syntax-ns#')
3+
const rdf = namespace('http://www.w3.org/1999/02/22-rdf-syntax-ns#')
44
const xsd = namespace('http://www.w3.org/2001/XMLSchema#')
55

66
export {

test/support/namespaces.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import namespace from '@rdfjs/namespace'
2+
3+
const rdf = namespace('http://www.w3.org/1999/02/22-rdf-syntax-ns#')
4+
const xsd = namespace('http://www.w3.org/2001/XMLSchema#')
5+
6+
export {
7+
rdf,
8+
xsd
9+
}

test/utils.test.js

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import { strictEqual } from 'assert'
2+
import rdf from '@rdfjs/data-model'
3+
import { describe, it } from 'mocha'
4+
import { isBoolean, isDecimal, isDouble, isLangString, isInteger, isString } from '../lib/utils.js'
5+
import * as ns from './support/namespaces.js'
6+
7+
describe('utils', () => {
8+
describe('isBoolean', () => {
9+
it('should be a function', () => {
10+
strictEqual(typeof isBoolean, 'function')
11+
})
12+
13+
it('should return true if the given term is a xsd:boolean literal', () => {
14+
const term = rdf.literal('true', ns.xsd.boolean)
15+
16+
strictEqual(isBoolean(term), true)
17+
})
18+
})
19+
20+
describe('isDecimal', () => {
21+
it('should be a function', () => {
22+
strictEqual(typeof isDecimal, 'function')
23+
})
24+
25+
it('should return true if the given term is a xsd:decimal literal', () => {
26+
const term = rdf.literal('12.34', ns.xsd.decimal)
27+
28+
strictEqual(isDecimal(term), true)
29+
})
30+
})
31+
32+
describe('isDouble', () => {
33+
it('should be a function', () => {
34+
strictEqual(typeof isDouble, 'function')
35+
})
36+
37+
it('should return true if the given term is a xsd:double literal', () => {
38+
const term = rdf.literal('1.2E3', ns.xsd.double)
39+
40+
strictEqual(isDouble(term), true)
41+
})
42+
})
43+
44+
describe('isLangString', () => {
45+
it('should be a function', () => {
46+
strictEqual(typeof isLangString, 'function')
47+
})
48+
49+
it('should return true if the given term is a rdf:langString literal', () => {
50+
const term = rdf.literal('Hello World!', 'en')
51+
52+
strictEqual(isLangString(term), true)
53+
})
54+
})
55+
56+
describe('isInteger', () => {
57+
it('should be a function', () => {
58+
strictEqual(typeof isInteger, 'function')
59+
})
60+
61+
it('should return true if the given term is a xsd:integer literal', () => {
62+
const term = rdf.literal('1234', ns.xsd.integer)
63+
64+
strictEqual(isInteger(term), true)
65+
})
66+
})
67+
68+
describe('isString', () => {
69+
it('should be a function', () => {
70+
strictEqual(typeof isString, 'function')
71+
})
72+
73+
it('should return true if the given term is a xsd:string literal', () => {
74+
const term = rdf.literal('Hello World!')
75+
76+
strictEqual(isString(term), true)
77+
})
78+
})
79+
})

0 commit comments

Comments
 (0)