equal
deleted
inserted
replaced
|
1 import Note from '../../store/noteRecord'; |
|
2 |
|
3 import WebAnnotationSerializer from '../WebAnnotationSerializer'; |
|
4 |
|
5 it('serializes as expected', () => { |
|
6 |
|
7 const category = { |
|
8 "key": "keyword", |
|
9 "name": "Mot-clé", |
|
10 "color": "#2ECC71", |
|
11 "text": "Foo" |
|
12 }; |
|
13 |
|
14 const comment = { |
|
15 "key": "comment", |
|
16 "name": "Commentaire", |
|
17 "color": "#3498DB", |
|
18 "hasComment": true, |
|
19 "comment": "Bar", |
|
20 "text": "Baz" |
|
21 } |
|
22 |
|
23 const note = new Note({ |
|
24 _id: '123456', |
|
25 session: '9876543', |
|
26 |
|
27 plain: 'Foo', |
|
28 raw: {}, |
|
29 html: '', |
|
30 |
|
31 startedAt: '', |
|
32 finishedAt: '', |
|
33 |
|
34 categories: [ category, comment ], |
|
35 |
|
36 marginComment: '' |
|
37 }) |
|
38 |
|
39 const actual = WebAnnotationSerializer.serialize(note); |
|
40 |
|
41 const expected = [ |
|
42 { |
|
43 "@context": "http://www.w3.org/ns/anno.jsonld", |
|
44 "type": "Annotation", |
|
45 "id": 0, |
|
46 "target": { |
|
47 "source": "/session/9876543/notes/123456", |
|
48 "selector": { |
|
49 "type": "TextQuoteSelector", |
|
50 "exact": "Foo" |
|
51 } |
|
52 } |
|
53 }, |
|
54 { |
|
55 "@context": "http://www.w3.org/ns/anno.jsonld", |
|
56 "type": "Annotation", |
|
57 "id": 1, |
|
58 "body": { |
|
59 "type": "TextualBody", |
|
60 "value": "Bar", |
|
61 "format": "text/plain" |
|
62 }, |
|
63 "target": { |
|
64 "source": "/session/9876543/notes/123456", |
|
65 "selector": { |
|
66 "type": "TextQuoteSelector", |
|
67 "exact": "Baz" |
|
68 } |
|
69 } |
|
70 } |
|
71 ]; |
|
72 |
|
73 // console.log(JSON.stringify(actual, null, 2)); |
|
74 |
|
75 expect(actual).toMatchObject(expected); |
|
76 }); |