|
1 | | -import { sym } from 'rdflib' |
| 1 | +import { lit, sym } from 'rdflib' |
2 | 2 | import { label } from '../../../src/utils' |
3 | 3 | import { silenceDebugMessages } from '../../helpers/setup' |
| 4 | +import { store } from '../../../src/logic' |
| 5 | +import * as ns from '../../../src/ns' |
4 | 6 | silenceDebugMessages() |
5 | 7 | jest.mock('solid-auth-client', () => ({ |
6 | 8 | currentSession: () => Promise.resolve(), |
7 | 9 | trackSession: () => null |
8 | 10 | })) |
9 | 11 | 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 | + |
10 | 39 | describe('when no label predicates are present', () => { |
11 | 40 | it('the hostname is used when no path is present', () => { |
12 | 41 | const result = label(sym('https://resource.example/')) |
|
0 commit comments