Skip to content

Commit 139fce4

Browse files
committed
use snapshots for long test results
Signed-off-by: grnd-alt <github@belakkaf.net>
1 parent fb8b852 commit 139fce4

2 files changed

Lines changed: 132 additions & 67 deletions

File tree

src/tests/marks/Link.spec.js

Lines changed: 5 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -19,63 +19,17 @@ describe('Link extension integrated in the editor', () => {
1919
)
2020
editor.commands.setTextSelection(3)
2121
editor.commands.insertOrSetLink('updated.de', { href: 'updated.de' })
22-
expect(editor.getJSON()).toEqual({
23-
content: [
24-
{
25-
content: [
26-
{
27-
marks: [
28-
{ attrs: { href: 'updated.de', title: null }, type: 'link' },
29-
],
30-
text: 'updated.de',
31-
type: 'text',
32-
},
33-
{ text: ' HELLO WORLD', type: 'text' },
34-
],
35-
type: 'paragraph',
36-
},
37-
],
38-
type: 'doc',
39-
})
22+
expect(editor.getJSON()).toMatchSnapshot()
4023
})
4124

4225
it('Should only update link the anchor is on', () => {
4326
const editor = createCustomEditor(
44-
'<p><a href="nextcloud.com">Test</a><a href="not-nextcloud.com">second link</a></p>',
27+
'<p><a href="nextcloud.com">Test</a><a href="not-nextcloud.com">second link</a></p>',
4528
[Link],
4629
)
4730
editor.commands.setTextSelection(3)
4831
editor.commands.insertOrSetLink('updated.de', { href: 'updated.de' })
49-
expect(editor.getJSON()).toEqual({
50-
content: [
51-
{
52-
content: [
53-
{
54-
marks: [
55-
{ attrs: { href: 'updated.de', title: null }, type: 'link' },
56-
],
57-
text: 'updated.de',
58-
type: 'text',
59-
},
60-
{
61-
marks: [
62-
{
63-
attrs: {
64-
href: 'not-nextcloud.com',
65-
title: null,
66-
},
67-
type: 'link',
68-
},
69-
],
70-
text: 'second link',
71-
type: 'text',
72-
},
73-
],
74-
type: 'paragraph',
75-
},
76-
],
77-
type: 'doc',
78-
})
32+
expect(editor.getJSON()).toMatchSnapshot()
7933
})
8034

8135
it('should insert new link if none at anchor', () => {
@@ -84,23 +38,7 @@ describe('Link extension integrated in the editor', () => {
8438
[Link],
8539
)
8640
editor.commands.setTextSelection(10)
87-
expect(editor.getJSON()).toEqual({
88-
content: [
89-
{
90-
content: [
91-
{
92-
marks: [
93-
{ attrs: { href: 'nextcloud.com', title: null }, type: 'link' },
94-
],
95-
text: 'Test',
96-
type: 'text',
97-
},
98-
{ text: ' HELLO WORLD', type: 'text' },
99-
],
100-
type: 'paragraph',
101-
},
102-
],
103-
type: 'doc',
104-
})
41+
editor.commands.insertOrSetLink('new link', { href: 'https://nextcloud.com' })
42+
expect(editor.getJSON()).toMatchSnapshot()
10543
})
10644
})
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2+
3+
exports[`Link extension integrated in the editor > Should only update link the anchor is on 1`] = `
4+
{
5+
"content": [
6+
{
7+
"content": [
8+
{
9+
"marks": [
10+
{
11+
"attrs": {
12+
"href": "updated.de",
13+
"title": null,
14+
},
15+
"type": "link",
16+
},
17+
],
18+
"text": "updated.de",
19+
"type": "text",
20+
},
21+
{
22+
"marks": [
23+
{
24+
"attrs": {
25+
"href": "not-nextcloud.com",
26+
"title": null,
27+
},
28+
"type": "link",
29+
},
30+
],
31+
"text": "second link",
32+
"type": "text",
33+
},
34+
],
35+
"type": "paragraph",
36+
},
37+
],
38+
"type": "doc",
39+
}
40+
`;
41+
42+
exports[`Link extension integrated in the editor > should insert new link if none at anchor 1`] = `
43+
{
44+
"content": [
45+
{
46+
"content": [
47+
{
48+
"marks": [
49+
{
50+
"attrs": {
51+
"href": "nextcloud.com",
52+
"title": null,
53+
},
54+
"type": "link",
55+
},
56+
],
57+
"text": "Test",
58+
"type": "text",
59+
},
60+
{
61+
"text": " HELL",
62+
"type": "text",
63+
},
64+
],
65+
"type": "paragraph",
66+
},
67+
{
68+
"content": [
69+
{
70+
"marks": [
71+
{
72+
"attrs": {
73+
"href": "https://nextcloud.com",
74+
"title": null,
75+
},
76+
"type": "link",
77+
},
78+
],
79+
"text": "new link",
80+
"type": "text",
81+
},
82+
],
83+
"type": "paragraph",
84+
},
85+
{
86+
"content": [
87+
{
88+
"text": "O WORLD",
89+
"type": "text",
90+
},
91+
],
92+
"type": "paragraph",
93+
},
94+
],
95+
"type": "doc",
96+
}
97+
`;
98+
99+
exports[`Link extension integrated in the editor > should update link if anchor has mark 1`] = `
100+
{
101+
"content": [
102+
{
103+
"content": [
104+
{
105+
"marks": [
106+
{
107+
"attrs": {
108+
"href": "updated.de",
109+
"title": null,
110+
},
111+
"type": "link",
112+
},
113+
],
114+
"text": "updated.de",
115+
"type": "text",
116+
},
117+
{
118+
"text": " HELLO WORLD",
119+
"type": "text",
120+
},
121+
],
122+
"type": "paragraph",
123+
},
124+
],
125+
"type": "doc",
126+
}
127+
`;

0 commit comments

Comments
 (0)