-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmod_test.ts
36 lines (29 loc) · 970 Bytes
/
mod_test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { Converter } from './mod.ts'
import { assertEquals } from 'https://deno.land/[email protected]/testing/asserts.ts'
const expectedType1 = `export type selfPhilosopher = {
label?: string | Array<string>;
thumb: string;
type: string;
birthPlace?: Array<selfLocation>;
birthDate?: Date;
}
`
const expectedType2 = `export type selfLocation = {
type: string;
name: string;
}
`
Deno.test('Output of transform', async () => {
const response = await fetch('https://deno.land/x/[email protected]/shapes/Person.ttl')
const personShacl = await response.text()
const converter = new Converter()
const context = {
'label': 'rdfs:label',
'type': 'rdf:type',
'name': 'foaf:name',
'thumb': 'dbo:thumbnail'
}
const typeScriptTypes = await converter.transform(personShacl, 'dbp', context)
assertEquals(typeScriptTypes[0].text, expectedType1)
assertEquals(typeScriptTypes[1].text, expectedType2)
})