solid-panes
Version:
Solid-compatible Panes: applets and views for the mashlib and databrowser
37 lines (31 loc) • 1.22 kB
text/typescript
/* eslint-env jest */
import { TextEncoder, TextDecoder } from 'util'
global.TextEncoder = TextEncoder as any
global.TextDecoder = TextDecoder as any
import { sym } from 'rdflib'
import { propertyViews } from './propertyViews'
describe('property views', () => {
it.each([
'http://xmlns.com/foaf/0.1/depiction',
'http://xmlns.com/foaf/0.1/img',
'http://xmlns.com/foaf/0.1/thumbnail',
'http://xmlns.com/foaf/0.1/logo',
'http://schema.org/image'
])('renders %s as image', (property) => {
const views = propertyViews(document)
const view = views.defaults[property]
const result = view(sym('https://pod.example/img.jpg'))
expect(result).toBeInstanceOf(HTMLImageElement)
expect(result).toHaveAttribute('src', 'https://pod.example/img.jpg')
})
it.each([
'http://xmlns.com/foaf/0.1/mbox'
])('renders %s as anchor', (property) => {
const views = propertyViews(document)
const view = views.defaults[property]
const result = view(sym('mailto:alice@mail.example'))
expect(result).toBeInstanceOf(HTMLAnchorElement)
expect(result).toHaveAttribute('href', 'mailto:alice@mail.example');
expect(result).toHaveTextContent('alice@mail.example');
})
})