This repository has been archived by the owner on Sep 3, 2023. It is now read-only.
/
index.test.ts
67 lines (64 loc) · 2.21 KB
/
index.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import { expect } from 'vitest'
import { injectSchemaOrg, useSchemaOrg, useSetup } from '../../../.test'
import { defineBook, defineBookEdition, definePerson } from '#provider'
describe('defineCourse', () => {
it('can be registered', () => {
useSetup(() => {
useSchemaOrg([
defineBook({
url: 'http://example.com/work/the_catcher_in_the_rye',
name: 'The Catcher in the Rye',
author: definePerson({
name: 'J.D. Salinger',
}),
sameAs: 'https://en.wikipedia.org/wiki/The_Catcher_in_the_Rye',
workExample: [
defineBookEdition({
isbn: '9787543321724',
bookEdition: 'Mass Market Paperback',
bookFormat: 'https://schema.org/Paperback',
inLanguage: 'en',
url: 'http://example.com/edition/the_catcher_in_the_rye_paperback',
datePublished: '1991-05-01',
identifier: {
'@type': 'PropertyValue',
'propertyID': 'OCLC_NUMBER',
'value': '1057320822',
},
}),
],
}),
])
const { graphNodes } = injectSchemaOrg()
expect(graphNodes).toMatchInlineSnapshot(`
[
{
"@id": "https://example.com/#book",
"@type": "Book",
"author": {
"@type": "Person",
"name": "J.D. Salinger",
},
"name": "The Catcher in the Rye",
"sameAs": "https://en.wikipedia.org/wiki/The_Catcher_in_the_Rye",
"url": "http://example.com/work/the_catcher_in_the_rye",
"workExample": {
"@type": "Book",
"bookEdition": "Mass Market Paperback",
"bookFormat": "https://schema.org/Paperback",
"datePublished": "1991-4-1",
"identifier": {
"@type": "PropertyValue",
"propertyID": "OCLC_NUMBER",
"value": "1057320822",
},
"inLanguage": "en",
"isbn": "9787543321724",
"url": "http://example.com/edition/the_catcher_in_the_rye_paperback",
},
},
]
`)
})
})
})