Skip to content

Commit a92be35

Browse files
committed
add tests for well-known label predicates
1 parent 3325d3e commit a92be35

1 file changed

Lines changed: 30 additions & 1 deletion

File tree

test/unit/utils/label.test.ts

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,41 @@
1-
import { sym } from 'rdflib'
1+
import { lit, sym } from 'rdflib'
22
import { label } from '../../../src/utils'
33
import { silenceDebugMessages } from '../../helpers/setup'
4+
import { store } from '../../../src/logic'
5+
import * as ns from '../../../src/ns'
46
silenceDebugMessages()
57
jest.mock('solid-auth-client', () => ({
68
currentSession: () => Promise.resolve(),
79
trackSession: () => null
810
}))
911
describe('label', () => {
12+
describe('uses well known label predicates', () => {
13+
const thing = sym('https://resource.example/label-test#it')
14+
15+
beforeEach(() => {
16+
store.removeDocument(thing.doc())
17+
})
18+
19+
it.each([
20+
'http://www.w3.org/ns/ui#label',
21+
'http://www.w3.org/2007/ont/link#message',
22+
'http://www.w3.org/2006/vcard/ns#fn',
23+
'http://xmlns.com/foaf/0.1/name',
24+
'http://purl.org/dc/terms/title',
25+
'http://purl.org/dc/elements/1.1/title',
26+
'http://purl.org/rss/1.0/title',
27+
'http://www.w3.org/2000/10/swap/pim/contact#fullName',
28+
'http://www.w3.org/2001/04/roadmap/org#name',
29+
'http://www.w3.org/2002/12/cal/ical#summary',
30+
'http://xmlns.com/foaf/0.1/nick',
31+
'http://www.w3.org/2000/01/rdf-schema#label'
32+
])('renders %s as label', (property) => {
33+
store.add(thing, sym(property), lit('the label'), thing.doc())
34+
const result = label(thing)
35+
expect(result).toEqual('the label')
36+
})
37+
})
38+
1039
describe('when no label predicates are present', () => {
1140
it('the hostname is used when no path is present', () => {
1241
const result = label(sym('https://resource.example/'))

0 commit comments

Comments
 (0)