@contentful/field-editor-markdown 2.2.0 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,22 +2,23 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
+ const _vitest = require("vitest");
5
6
  const _InsertLinkModalDialog = require("./dialogs/InsertLinkModalDialog");
6
7
  const _InsertTableModalDialog = require("./dialogs/InsertTableModalDialog");
7
8
  const _SpecialCharacterModalDialog = require("./dialogs/SpecialCharacterModalDialog");
8
9
  const _ZenModeModalDialog = require("./dialogs/ZenModeModalDialog");
9
10
  const _MarkdownActions = require("./MarkdownActions");
10
- jest.mock('./dialogs/InsertLinkModalDialog', ()=>({
11
- openInsertLinkDialog: jest.fn()
11
+ _vitest.vi.mock('./dialogs/InsertLinkModalDialog', ()=>({
12
+ openInsertLinkDialog: _vitest.vi.fn()
12
13
  }));
13
- jest.mock('./dialogs/SpecialCharacterModalDialog', ()=>({
14
- openInsertSpecialCharacter: jest.fn()
14
+ _vitest.vi.mock('./dialogs/SpecialCharacterModalDialog', ()=>({
15
+ openInsertSpecialCharacter: _vitest.vi.fn()
15
16
  }));
16
- jest.mock('./dialogs/InsertTableModalDialog', ()=>({
17
- openInsertTableDialog: jest.fn()
17
+ _vitest.vi.mock('./dialogs/InsertTableModalDialog', ()=>({
18
+ openInsertTableDialog: _vitest.vi.fn()
18
19
  }));
19
- jest.mock('./dialogs/ZenModeModalDialog', ()=>({
20
- openZenMode: jest.fn()
20
+ _vitest.vi.mock('./dialogs/ZenModeModalDialog', ()=>({
21
+ openZenMode: _vitest.vi.fn()
21
22
  }));
22
23
  const mockedOpenInsertLinkDialog = _InsertLinkModalDialog.openInsertLinkDialog;
23
24
  const mockedOpenInsertSpecialCharacter = _SpecialCharacterModalDialog.openInsertSpecialCharacter;
@@ -25,31 +26,31 @@ const mockedOpenInsertTableDialog = _InsertTableModalDialog.openInsertTableDialo
25
26
  const mockedOpenZenMode = _ZenModeModalDialog.openZenMode;
26
27
  const createEditor = ()=>({
27
28
  actions: {
28
- h1: jest.fn(),
29
- h2: jest.fn(),
30
- h3: jest.fn(),
31
- bold: jest.fn(),
32
- italic: jest.fn(),
33
- quote: jest.fn(),
34
- ol: jest.fn(),
35
- ul: jest.fn(),
36
- strike: jest.fn(),
37
- code: jest.fn(),
38
- hr: jest.fn(),
39
- indent: jest.fn(),
40
- dedent: jest.fn(),
41
- undo: jest.fn(),
42
- redo: jest.fn(),
43
- link: jest.fn(),
44
- table: jest.fn()
29
+ h1: _vitest.vi.fn(),
30
+ h2: _vitest.vi.fn(),
31
+ h3: _vitest.vi.fn(),
32
+ bold: _vitest.vi.fn(),
33
+ italic: _vitest.vi.fn(),
34
+ quote: _vitest.vi.fn(),
35
+ ol: _vitest.vi.fn(),
36
+ ul: _vitest.vi.fn(),
37
+ strike: _vitest.vi.fn(),
38
+ code: _vitest.vi.fn(),
39
+ hr: _vitest.vi.fn(),
40
+ indent: _vitest.vi.fn(),
41
+ dedent: _vitest.vi.fn(),
42
+ undo: _vitest.vi.fn(),
43
+ redo: _vitest.vi.fn(),
44
+ link: _vitest.vi.fn(),
45
+ table: _vitest.vi.fn()
45
46
  },
46
- usePrimarySelection: jest.fn(),
47
- getSelectedText: jest.fn(),
48
- insert: jest.fn(),
49
- getContent: jest.fn(),
50
- setContent: jest.fn(),
51
- setCursor: jest.fn(),
52
- focus: jest.fn()
47
+ usePrimarySelection: _vitest.vi.fn(),
48
+ getSelectedText: _vitest.vi.fn(),
49
+ insert: _vitest.vi.fn(),
50
+ getContent: _vitest.vi.fn(),
51
+ setContent: _vitest.vi.fn(),
52
+ setCursor: _vitest.vi.fn(),
53
+ focus: _vitest.vi.fn()
53
54
  });
54
55
  const createSdk = ()=>({
55
56
  dialogs: {},
@@ -58,14 +59,14 @@ const createSdk = ()=>({
58
59
  fallbacks: {}
59
60
  },
60
61
  notifier: {
61
- success: jest.fn()
62
+ success: _vitest.vi.fn()
62
63
  }
63
64
  });
64
- describe('createMarkdownActions', ()=>{
65
- beforeEach(()=>{
66
- jest.clearAllMocks();
65
+ (0, _vitest.describe)('createMarkdownActions', ()=>{
66
+ (0, _vitest.beforeEach)(()=>{
67
+ _vitest.vi.clearAllMocks();
67
68
  });
68
- it('dispatches toolbar actions to the editor', ()=>{
69
+ (0, _vitest.it)('dispatches toolbar actions to the editor', ()=>{
69
70
  const editor = createEditor();
70
71
  const actions = (0, _MarkdownActions.createMarkdownActions)({
71
72
  sdk: createSdk(),
@@ -76,12 +77,12 @@ describe('createMarkdownActions', ()=>{
76
77
  actions.simple.bold();
77
78
  actions.simple.ul();
78
79
  actions.history.undo();
79
- expect(editor.actions.h2).toHaveBeenCalledTimes(1);
80
- expect(editor.actions.bold).toHaveBeenCalledTimes(1);
81
- expect(editor.actions.ul).toHaveBeenCalledTimes(1);
82
- expect(editor.actions.undo).toHaveBeenCalledTimes(1);
80
+ (0, _vitest.expect)(editor.actions.h2).toHaveBeenCalledTimes(1);
81
+ (0, _vitest.expect)(editor.actions.bold).toHaveBeenCalledTimes(1);
82
+ (0, _vitest.expect)(editor.actions.ul).toHaveBeenCalledTimes(1);
83
+ (0, _vitest.expect)(editor.actions.undo).toHaveBeenCalledTimes(1);
83
84
  });
84
- it('opens the link dialog with the selected text and inserts a titled link', async ()=>{
85
+ (0, _vitest.it)('opens the link dialog with the selected text and inserts a titled link', async ()=>{
85
86
  const editor = createEditor();
86
87
  const sdk = createSdk();
87
88
  editor.getSelectedText.mockReturnValue('Contentful');
@@ -96,13 +97,13 @@ describe('createMarkdownActions', ()=>{
96
97
  locale: 'en-US'
97
98
  });
98
99
  await actions.insertLink();
99
- expect(editor.usePrimarySelection).toHaveBeenCalledTimes(1);
100
- expect(mockedOpenInsertLinkDialog).toHaveBeenCalledWith(sdk.dialogs, {
100
+ (0, _vitest.expect)(editor.usePrimarySelection).toHaveBeenCalledTimes(1);
101
+ (0, _vitest.expect)(mockedOpenInsertLinkDialog).toHaveBeenCalledWith(sdk.dialogs, {
101
102
  selectedText: 'Contentful'
102
103
  });
103
- expect(editor.actions.link).toHaveBeenCalledWith('https://contentful.com', 'Contentful', 'The best headless CMS');
104
+ (0, _vitest.expect)(editor.actions.link).toHaveBeenCalledWith('https://contentful.com', 'Contentful', 'The best headless CMS');
104
105
  });
105
- it('falls back to dialog text when no editor selection exists', async ()=>{
106
+ (0, _vitest.it)('falls back to dialog text when no editor selection exists', async ()=>{
106
107
  const editor = createEditor();
107
108
  editor.getSelectedText.mockReturnValue('');
108
109
  mockedOpenInsertLinkDialog.mockResolvedValue({
@@ -116,9 +117,9 @@ describe('createMarkdownActions', ()=>{
116
117
  locale: 'en-US'
117
118
  });
118
119
  await actions.insertLink();
119
- expect(editor.actions.link).toHaveBeenCalledWith('https://contentful.com', 'Contentful', '');
120
+ (0, _vitest.expect)(editor.actions.link).toHaveBeenCalledWith('https://contentful.com', 'Contentful', '');
120
121
  });
121
- it('inserts special characters and tables from dialog results', async ()=>{
122
+ (0, _vitest.it)('inserts special characters and tables from dialog results', async ()=>{
122
123
  const editor = createEditor();
123
124
  mockedOpenInsertSpecialCharacter.mockResolvedValue('€');
124
125
  mockedOpenInsertTableDialog.mockResolvedValue({
@@ -132,13 +133,13 @@ describe('createMarkdownActions', ()=>{
132
133
  });
133
134
  await actions.insertSpecialCharacter();
134
135
  await actions.insertTable();
135
- expect(editor.insert).toHaveBeenCalledWith('€');
136
- expect(editor.actions.table).toHaveBeenCalledWith({
136
+ (0, _vitest.expect)(editor.insert).toHaveBeenCalledWith('€');
137
+ (0, _vitest.expect)(editor.actions.table).toHaveBeenCalledWith({
137
138
  rows: 2,
138
139
  cols: 3
139
140
  });
140
141
  });
141
- it('updates content and restores cursor when zen mode closes', async ()=>{
142
+ (0, _vitest.it)('updates content and restores cursor when zen mode closes', async ()=>{
142
143
  const editor = createEditor();
143
144
  mockedOpenZenMode.mockResolvedValue({
144
145
  value: 'updated markdown',
@@ -153,11 +154,11 @@ describe('createMarkdownActions', ()=>{
153
154
  locale: 'en-US'
154
155
  });
155
156
  await actions.openZenMode();
156
- expect(editor.setContent).toHaveBeenCalledWith('updated markdown');
157
- expect(editor.setCursor).toHaveBeenCalledWith({
157
+ (0, _vitest.expect)(editor.setContent).toHaveBeenCalledWith('updated markdown');
158
+ (0, _vitest.expect)(editor.setCursor).toHaveBeenCalledWith({
158
159
  line: 2,
159
160
  ch: 4
160
161
  });
161
- expect(editor.focus).toHaveBeenCalledTimes(1);
162
+ (0, _vitest.expect)(editor.focus).toHaveBeenCalledTimes(1);
162
163
  });
163
164
  });
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
5
  const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
6
- require("@testing-library/jest-dom/extend-expect");
7
6
  const _react1 = require("@testing-library/react");
8
7
  const _userevent = /*#__PURE__*/ _interop_require_default(require("@testing-library/user-event"));
8
+ const _vitest = require("vitest");
9
9
  const _MarkdownToolbar = require("./MarkdownToolbar");
10
10
  function _interop_require_default(obj) {
11
11
  return obj && obj.__esModule ? obj : {
@@ -62,42 +62,42 @@ const createProps = ()=>({
62
62
  mode: 'default',
63
63
  actions: {
64
64
  headings: {
65
- h1: jest.fn(),
66
- h2: jest.fn(),
67
- h3: jest.fn()
65
+ h1: _vitest.vi.fn(),
66
+ h2: _vitest.vi.fn(),
67
+ h3: _vitest.vi.fn()
68
68
  },
69
69
  simple: {
70
- bold: jest.fn(),
71
- italic: jest.fn(),
72
- quote: jest.fn(),
73
- ol: jest.fn(),
74
- ul: jest.fn(),
75
- strike: jest.fn(),
76
- code: jest.fn(),
77
- hr: jest.fn(),
78
- indent: jest.fn(),
79
- dedent: jest.fn()
70
+ bold: _vitest.vi.fn(),
71
+ italic: _vitest.vi.fn(),
72
+ quote: _vitest.vi.fn(),
73
+ ol: _vitest.vi.fn(),
74
+ ul: _vitest.vi.fn(),
75
+ strike: _vitest.vi.fn(),
76
+ code: _vitest.vi.fn(),
77
+ hr: _vitest.vi.fn(),
78
+ indent: _vitest.vi.fn(),
79
+ dedent: _vitest.vi.fn()
80
80
  },
81
81
  history: {
82
- undo: jest.fn(),
83
- redo: jest.fn()
82
+ undo: _vitest.vi.fn(),
83
+ redo: _vitest.vi.fn()
84
84
  },
85
- insertLink: jest.fn(),
86
- insertSpecialCharacter: jest.fn(),
87
- insertTable: jest.fn(),
88
- organizeLinks: jest.fn(),
89
- embedExternalContent: jest.fn(),
90
- linkExistingMedia: jest.fn(),
91
- addNewMedia: jest.fn(),
92
- openZenMode: jest.fn(),
93
- closeZenMode: jest.fn()
85
+ insertLink: _vitest.vi.fn(),
86
+ insertSpecialCharacter: _vitest.vi.fn(),
87
+ insertTable: _vitest.vi.fn(),
88
+ organizeLinks: _vitest.vi.fn(),
89
+ embedExternalContent: _vitest.vi.fn(),
90
+ linkExistingMedia: _vitest.vi.fn(),
91
+ addNewMedia: _vitest.vi.fn(),
92
+ openZenMode: _vitest.vi.fn(),
93
+ closeZenMode: _vitest.vi.fn()
94
94
  }
95
95
  });
96
- describe('MarkdownToolbar', ()=>{
97
- beforeEach(()=>{
98
- jest.clearAllMocks();
96
+ (0, _vitest.describe)('MarkdownToolbar', ()=>{
97
+ (0, _vitest.beforeEach)(()=>{
98
+ _vitest.vi.clearAllMocks();
99
99
  });
100
- it('opens the heading menu and calls the selected heading action', async ()=>{
100
+ (0, _vitest.it)('opens the heading menu and calls the selected heading action', async ()=>{
101
101
  const props = createProps();
102
102
  (0, _react1.render)(/*#__PURE__*/ _react.createElement(_MarkdownToolbar.MarkdownToolbar, props));
103
103
  await _userevent.default.click(_react1.screen.getByRole('button', {
@@ -106,32 +106,32 @@ describe('MarkdownToolbar', ()=>{
106
106
  await _userevent.default.click(_react1.screen.getByRole('menuitem', {
107
107
  name: 'Heading 1'
108
108
  }));
109
- expect(props.actions.headings.h1).toHaveBeenCalledTimes(1);
109
+ (0, _vitest.expect)(props.actions.headings.h1).toHaveBeenCalledTimes(1);
110
110
  });
111
- it('toggles additional actions and exposes the expanded state', async ()=>{
111
+ (0, _vitest.it)('toggles additional actions and exposes the expanded state', async ()=>{
112
112
  const props = createProps();
113
113
  (0, _react1.render)(/*#__PURE__*/ _react.createElement(_MarkdownToolbar.MarkdownToolbar, props));
114
114
  const toggle = _react1.screen.getByRole('button', {
115
115
  name: 'More actions'
116
116
  });
117
- expect(toggle).toHaveAttribute('aria-expanded', 'false');
117
+ (0, _vitest.expect)(toggle).toHaveAttribute('aria-expanded', 'false');
118
118
  await _userevent.default.click(toggle);
119
- expect(_react1.screen.getByRole('button', {
119
+ (0, _vitest.expect)(_react1.screen.getByRole('button', {
120
120
  name: 'Hide additional actions'
121
121
  })).toHaveAttribute('aria-expanded', 'true');
122
- expect(_react1.screen.getByRole('button', {
122
+ (0, _vitest.expect)(_react1.screen.getByRole('button', {
123
123
  name: 'Undo'
124
124
  })).toBeInTheDocument();
125
125
  });
126
- it('triggers a toolbar action once per click', async ()=>{
126
+ (0, _vitest.it)('triggers a toolbar action once per click', async ()=>{
127
127
  const props = createProps();
128
128
  (0, _react1.render)(/*#__PURE__*/ _react.createElement(_MarkdownToolbar.MarkdownToolbar, props));
129
129
  await _userevent.default.click(_react1.screen.getByRole('button', {
130
130
  name: 'Bold'
131
131
  }));
132
- expect(props.actions.simple.bold).toHaveBeenCalledTimes(1);
132
+ (0, _vitest.expect)(props.actions.simple.bold).toHaveBeenCalledTimes(1);
133
133
  });
134
- it('still supports keyboard-style activation', async ()=>{
134
+ (0, _vitest.it)('still supports keyboard-style activation', async ()=>{
135
135
  const props = createProps();
136
136
  (0, _react1.render)(/*#__PURE__*/ _react.createElement(_MarkdownToolbar.MarkdownToolbar, props));
137
137
  const bold = _react1.screen.getByRole('button', {
@@ -139,6 +139,6 @@ describe('MarkdownToolbar', ()=>{
139
139
  });
140
140
  bold.focus();
141
141
  await _userevent.default.keyboard('{Enter}');
142
- expect(props.actions.simple.bold).toHaveBeenCalledTimes(1);
142
+ (0, _vitest.expect)(props.actions.simple.bold).toHaveBeenCalledTimes(1);
143
143
  });
144
144
  });
@@ -2,21 +2,22 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
+ const _vitest = require("vitest");
5
6
  const _insertAssetLinks = require("./insertAssetLinks");
6
- describe('replaceAssetDomain', ()=>{
7
- it('should replace contentful.com domains to ctfassets.net', ()=>{
8
- expect((0, _insertAssetLinks.replaceAssetDomain)('//images.contentful.com/image.jpg')).toBe('//images.ctfassets.net/image.jpg');
9
- expect((0, _insertAssetLinks.replaceAssetDomain)('//videos.contentful.com/video.mp4')).toBe('//videos.ctfassets.net/video.mp4');
10
- expect((0, _insertAssetLinks.replaceAssetDomain)('//downloads.contentful.com/file.doc')).toBe('//downloads.ctfassets.net/file.doc');
11
- expect((0, _insertAssetLinks.replaceAssetDomain)('//assets.contentful.com/file.doc')).toBe('//assets.ctfassets.net/file.doc');
12
- expect((0, _insertAssetLinks.replaceAssetDomain)('https://images.contentful.com/image.jpg')).toBe('https://images.ctfassets.net/image.jpg');
13
- expect((0, _insertAssetLinks.replaceAssetDomain)('https://videos.contentful.com/video.mp4')).toBe('https://videos.ctfassets.net/video.mp4');
14
- expect((0, _insertAssetLinks.replaceAssetDomain)('https://downloads.contentful.com/file.doc')).toBe('https://downloads.ctfassets.net/file.doc');
15
- expect((0, _insertAssetLinks.replaceAssetDomain)('https://assets.contentful.com/file.doc')).toBe('https://assets.ctfassets.net/file.doc');
7
+ (0, _vitest.describe)('replaceAssetDomain', ()=>{
8
+ (0, _vitest.it)('should replace contentful.com domains to ctfassets.net', ()=>{
9
+ (0, _vitest.expect)((0, _insertAssetLinks.replaceAssetDomain)('//images.contentful.com/image.jpg')).toBe('//images.ctfassets.net/image.jpg');
10
+ (0, _vitest.expect)((0, _insertAssetLinks.replaceAssetDomain)('//videos.contentful.com/video.mp4')).toBe('//videos.ctfassets.net/video.mp4');
11
+ (0, _vitest.expect)((0, _insertAssetLinks.replaceAssetDomain)('//downloads.contentful.com/file.doc')).toBe('//downloads.ctfassets.net/file.doc');
12
+ (0, _vitest.expect)((0, _insertAssetLinks.replaceAssetDomain)('//assets.contentful.com/file.doc')).toBe('//assets.ctfassets.net/file.doc');
13
+ (0, _vitest.expect)((0, _insertAssetLinks.replaceAssetDomain)('https://images.contentful.com/image.jpg')).toBe('https://images.ctfassets.net/image.jpg');
14
+ (0, _vitest.expect)((0, _insertAssetLinks.replaceAssetDomain)('https://videos.contentful.com/video.mp4')).toBe('https://videos.ctfassets.net/video.mp4');
15
+ (0, _vitest.expect)((0, _insertAssetLinks.replaceAssetDomain)('https://downloads.contentful.com/file.doc')).toBe('https://downloads.ctfassets.net/file.doc');
16
+ (0, _vitest.expect)((0, _insertAssetLinks.replaceAssetDomain)('https://assets.contentful.com/file.doc')).toBe('https://assets.ctfassets.net/file.doc');
16
17
  });
17
- it('should not replace domains not listed on the map', ()=>{
18
- expect((0, _insertAssetLinks.replaceAssetDomain)('//documents.contentful.com/image.jpg')).toBe('//documents.contentful.com/image.jpg');
19
- expect((0, _insertAssetLinks.replaceAssetDomain)('anyotherdomain.com/file.doc')).toBe('anyotherdomain.com/file.doc');
20
- expect((0, _insertAssetLinks.replaceAssetDomain)('https://anyotherdomain.com/file.doc')).toBe('https://anyotherdomain.com/file.doc');
18
+ (0, _vitest.it)('should not replace domains not listed on the map', ()=>{
19
+ (0, _vitest.expect)((0, _insertAssetLinks.replaceAssetDomain)('//documents.contentful.com/image.jpg')).toBe('//documents.contentful.com/image.jpg');
20
+ (0, _vitest.expect)((0, _insertAssetLinks.replaceAssetDomain)('anyotherdomain.com/file.doc')).toBe('anyotherdomain.com/file.doc');
21
+ (0, _vitest.expect)((0, _insertAssetLinks.replaceAssetDomain)('https://anyotherdomain.com/file.doc')).toBe('https://anyotherdomain.com/file.doc');
21
22
  });
22
23
  });
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
+ const _vitest = require("vitest");
5
6
  const _linkOrganizer = /*#__PURE__*/ _interop_require_wildcard(require("./linkOrganizer"));
6
7
  function _getRequireWildcardCache(nodeInterop) {
7
8
  if (typeof WeakMap !== "function") return null;
@@ -44,55 +45,55 @@ function _interop_require_wildcard(obj, nodeInterop) {
44
45
  }
45
46
  return newObj;
46
47
  }
47
- describe('Link organizer', ()=>{
48
- describe('Inline link finder', ()=>{
49
- it('Finds all inline links in text', ()=>{
48
+ (0, _vitest.describe)('Link organizer', ()=>{
49
+ (0, _vitest.describe)('Inline link finder', ()=>{
50
+ (0, _vitest.it)('Finds all inline links in text', ()=>{
50
51
  const subject = 'test [link](http://url.com) test [link2](http://url2.com) test [link3](http://url.com)';
51
52
  const found = _linkOrganizer.findInline(subject);
52
- expect(found).toHaveLength(3);
53
- expect(found[0].match).toBe('[link](http://url.com)');
54
- expect(found[0].text).toBe('link');
55
- expect(found[0].href).toBe('http://url.com');
56
- expect(found[0].title).toBe('');
53
+ (0, _vitest.expect)(found).toHaveLength(3);
54
+ (0, _vitest.expect)(found[0].match).toBe('[link](http://url.com)');
55
+ (0, _vitest.expect)(found[0].text).toBe('link');
56
+ (0, _vitest.expect)(found[0].href).toBe('http://url.com');
57
+ (0, _vitest.expect)(found[0].title).toBe('');
57
58
  });
58
- it('Finds and standardizes title', ()=>{
59
+ (0, _vitest.it)('Finds and standardizes title', ()=>{
59
60
  const subject = 'test [x](http://url.com "title!") [y](http://xyz.com title 2 )';
60
61
  const found = _linkOrganizer.findInline(subject);
61
- expect(found).toHaveLength(2);
62
- expect(found[0].title).toBe('title!');
63
- expect(found[1].title).toBe('title 2');
62
+ (0, _vitest.expect)(found).toHaveLength(2);
63
+ (0, _vitest.expect)(found[0].title).toBe('title!');
64
+ (0, _vitest.expect)(found[1].title).toBe('title 2');
64
65
  });
65
66
  });
66
- describe('Reference finder', ()=>{
67
- it('Finds all references in text', ()=>{
67
+ (0, _vitest.describe)('Reference finder', ()=>{
68
+ (0, _vitest.it)('Finds all references in text', ()=>{
68
69
  const subject = 'test [x][1] test [y][2] [with space separator] [3]';
69
70
  const found = _linkOrganizer.findRefs(subject);
70
- expect(found).toHaveLength(3);
71
- expect(found[0].match).toBe('[x][1]');
72
- expect(found[2].match).toBe('[with space separator] [3]');
73
- expect(found[1].text).toBe('y');
74
- expect(found[1].id).toBe('2');
71
+ (0, _vitest.expect)(found).toHaveLength(3);
72
+ (0, _vitest.expect)(found[0].match).toBe('[x][1]');
73
+ (0, _vitest.expect)(found[2].match).toBe('[with space separator] [3]');
74
+ (0, _vitest.expect)(found[1].text).toBe('y');
75
+ (0, _vitest.expect)(found[1].id).toBe('2');
75
76
  });
76
77
  });
77
- describe('Label finder', ()=>{
78
+ (0, _vitest.describe)('Label finder', ()=>{
78
79
  const subject = [
79
80
  '[1]: http://test.com',
80
81
  '[2]: http://url.com',
81
82
  '[string]: http://url.com',
82
83
  '[4]: http://test.com "Hello world"'
83
84
  ].join('\n');
84
- it('Finds all labels', ()=>{
85
+ (0, _vitest.it)('Finds all labels', ()=>{
85
86
  const found = _linkOrganizer.findLabels(subject);
86
- expect(found).toHaveLength(4);
87
- expect(found[0].id).toBe('1');
88
- expect(found[2].id).toBe('string');
89
- expect(found[0].href).toBe('http://test.com');
90
- expect(found[3].href).toBe('http://test.com');
91
- expect(found[1].title).toBe('');
92
- expect(found[3].title).toBe('Hello world');
87
+ (0, _vitest.expect)(found).toHaveLength(4);
88
+ (0, _vitest.expect)(found[0].id).toBe('1');
89
+ (0, _vitest.expect)(found[2].id).toBe('string');
90
+ (0, _vitest.expect)(found[0].href).toBe('http://test.com');
91
+ (0, _vitest.expect)(found[3].href).toBe('http://test.com');
92
+ (0, _vitest.expect)(found[1].title).toBe('');
93
+ (0, _vitest.expect)(found[3].title).toBe('Hello world');
93
94
  });
94
- it('Finds max label id', ()=>{
95
- expect(_linkOrganizer.findMaxLabelId(subject)).toBe(4);
95
+ (0, _vitest.it)('Finds max label id', ()=>{
96
+ (0, _vitest.expect)(_linkOrganizer.findMaxLabelId(subject)).toBe(4);
96
97
  });
97
98
  });
98
99
  });
@@ -2,21 +2,22 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
+ const _vitest = require("vitest");
5
6
  const _replaceMailtoAmp = require("./replaceMailtoAmp");
6
- describe('replace inside mailto', ()=>{
7
+ (0, _vitest.describe)('replace inside mailto', ()=>{
7
8
  let str = '<a href="mailto:example@example.com?subject=Hello&amp;body=Hello%20world">Send Email</a>';
8
- test('replace &amp; with &', ()=>{
9
+ (0, _vitest.test)('replace &amp; with &', ()=>{
9
10
  const newStr = (0, _replaceMailtoAmp.replaceMailtoAmp)(str);
10
- expect(newStr).toBe('<a href="mailto:example@example.com?subject=Hello&body=Hello%20world">Send Email</a>');
11
+ (0, _vitest.expect)(newStr).toBe('<a href="mailto:example@example.com?subject=Hello&body=Hello%20world">Send Email</a>');
11
12
  });
12
- test('no replace if not inside mailto', ()=>{
13
+ (0, _vitest.test)('no replace if not inside mailto', ()=>{
13
14
  str = '<a href="https://example.com?subject=Hello&amp;body=Hello%20world">Visit Website</a>';
14
15
  const newStr = (0, _replaceMailtoAmp.replaceMailtoAmp)(str);
15
- expect(newStr).toBe('<a href="https://example.com?subject=Hello&amp;body=Hello%20world">Visit Website</a>');
16
+ (0, _vitest.expect)(newStr).toBe('<a href="https://example.com?subject=Hello&amp;body=Hello%20world">Visit Website</a>');
16
17
  });
17
- test('no replace if no &amp;', ()=>{
18
+ (0, _vitest.test)('no replace if no &amp;', ()=>{
18
19
  str = '<a href="mailto:example@example.com?subject=Hello">Send Email</a>';
19
20
  const newStr = (0, _replaceMailtoAmp.replaceMailtoAmp)(str);
20
- expect(newStr).toBe('<a href="mailto:example@example.com?subject=Hello">Send Email</a>');
21
+ (0, _vitest.expect)(newStr).toBe('<a href="mailto:example@example.com?subject=Hello">Send Email</a>');
21
22
  });
22
23
  });
@@ -1,14 +1,15 @@
1
- jest.mock('./dialogs/InsertLinkModalDialog', ()=>({
2
- openInsertLinkDialog: jest.fn()
1
+ import { beforeEach, describe, expect, it, vi } from 'vitest';
2
+ vi.mock('./dialogs/InsertLinkModalDialog', ()=>({
3
+ openInsertLinkDialog: vi.fn()
3
4
  }));
4
- jest.mock('./dialogs/SpecialCharacterModalDialog', ()=>({
5
- openInsertSpecialCharacter: jest.fn()
5
+ vi.mock('./dialogs/SpecialCharacterModalDialog', ()=>({
6
+ openInsertSpecialCharacter: vi.fn()
6
7
  }));
7
- jest.mock('./dialogs/InsertTableModalDialog', ()=>({
8
- openInsertTableDialog: jest.fn()
8
+ vi.mock('./dialogs/InsertTableModalDialog', ()=>({
9
+ openInsertTableDialog: vi.fn()
9
10
  }));
10
- jest.mock('./dialogs/ZenModeModalDialog', ()=>({
11
- openZenMode: jest.fn()
11
+ vi.mock('./dialogs/ZenModeModalDialog', ()=>({
12
+ openZenMode: vi.fn()
12
13
  }));
13
14
  import { openInsertLinkDialog } from './dialogs/InsertLinkModalDialog';
14
15
  import { openInsertTableDialog } from './dialogs/InsertTableModalDialog';
@@ -21,31 +22,31 @@ const mockedOpenInsertTableDialog = openInsertTableDialog;
21
22
  const mockedOpenZenMode = openZenMode;
22
23
  const createEditor = ()=>({
23
24
  actions: {
24
- h1: jest.fn(),
25
- h2: jest.fn(),
26
- h3: jest.fn(),
27
- bold: jest.fn(),
28
- italic: jest.fn(),
29
- quote: jest.fn(),
30
- ol: jest.fn(),
31
- ul: jest.fn(),
32
- strike: jest.fn(),
33
- code: jest.fn(),
34
- hr: jest.fn(),
35
- indent: jest.fn(),
36
- dedent: jest.fn(),
37
- undo: jest.fn(),
38
- redo: jest.fn(),
39
- link: jest.fn(),
40
- table: jest.fn()
25
+ h1: vi.fn(),
26
+ h2: vi.fn(),
27
+ h3: vi.fn(),
28
+ bold: vi.fn(),
29
+ italic: vi.fn(),
30
+ quote: vi.fn(),
31
+ ol: vi.fn(),
32
+ ul: vi.fn(),
33
+ strike: vi.fn(),
34
+ code: vi.fn(),
35
+ hr: vi.fn(),
36
+ indent: vi.fn(),
37
+ dedent: vi.fn(),
38
+ undo: vi.fn(),
39
+ redo: vi.fn(),
40
+ link: vi.fn(),
41
+ table: vi.fn()
41
42
  },
42
- usePrimarySelection: jest.fn(),
43
- getSelectedText: jest.fn(),
44
- insert: jest.fn(),
45
- getContent: jest.fn(),
46
- setContent: jest.fn(),
47
- setCursor: jest.fn(),
48
- focus: jest.fn()
43
+ usePrimarySelection: vi.fn(),
44
+ getSelectedText: vi.fn(),
45
+ insert: vi.fn(),
46
+ getContent: vi.fn(),
47
+ setContent: vi.fn(),
48
+ setCursor: vi.fn(),
49
+ focus: vi.fn()
49
50
  });
50
51
  const createSdk = ()=>({
51
52
  dialogs: {},
@@ -54,12 +55,12 @@ const createSdk = ()=>({
54
55
  fallbacks: {}
55
56
  },
56
57
  notifier: {
57
- success: jest.fn()
58
+ success: vi.fn()
58
59
  }
59
60
  });
60
61
  describe('createMarkdownActions', ()=>{
61
62
  beforeEach(()=>{
62
- jest.clearAllMocks();
63
+ vi.clearAllMocks();
63
64
  });
64
65
  it('dispatches toolbar actions to the editor', ()=>{
65
66
  const editor = createEditor();
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
- import '@testing-library/jest-dom/extend-expect';
3
2
  import { configure, render, screen } from '@testing-library/react';
4
3
  import userEvent from '@testing-library/user-event';
4
+ import { beforeEach, describe, expect, it, vi } from 'vitest';
5
5
  import { MarkdownToolbar } from './MarkdownToolbar';
6
6
  configure({
7
7
  testIdAttribute: 'data-test-id'
@@ -12,40 +12,40 @@ const createProps = ()=>({
12
12
  mode: 'default',
13
13
  actions: {
14
14
  headings: {
15
- h1: jest.fn(),
16
- h2: jest.fn(),
17
- h3: jest.fn()
15
+ h1: vi.fn(),
16
+ h2: vi.fn(),
17
+ h3: vi.fn()
18
18
  },
19
19
  simple: {
20
- bold: jest.fn(),
21
- italic: jest.fn(),
22
- quote: jest.fn(),
23
- ol: jest.fn(),
24
- ul: jest.fn(),
25
- strike: jest.fn(),
26
- code: jest.fn(),
27
- hr: jest.fn(),
28
- indent: jest.fn(),
29
- dedent: jest.fn()
20
+ bold: vi.fn(),
21
+ italic: vi.fn(),
22
+ quote: vi.fn(),
23
+ ol: vi.fn(),
24
+ ul: vi.fn(),
25
+ strike: vi.fn(),
26
+ code: vi.fn(),
27
+ hr: vi.fn(),
28
+ indent: vi.fn(),
29
+ dedent: vi.fn()
30
30
  },
31
31
  history: {
32
- undo: jest.fn(),
33
- redo: jest.fn()
32
+ undo: vi.fn(),
33
+ redo: vi.fn()
34
34
  },
35
- insertLink: jest.fn(),
36
- insertSpecialCharacter: jest.fn(),
37
- insertTable: jest.fn(),
38
- organizeLinks: jest.fn(),
39
- embedExternalContent: jest.fn(),
40
- linkExistingMedia: jest.fn(),
41
- addNewMedia: jest.fn(),
42
- openZenMode: jest.fn(),
43
- closeZenMode: jest.fn()
35
+ insertLink: vi.fn(),
36
+ insertSpecialCharacter: vi.fn(),
37
+ insertTable: vi.fn(),
38
+ organizeLinks: vi.fn(),
39
+ embedExternalContent: vi.fn(),
40
+ linkExistingMedia: vi.fn(),
41
+ addNewMedia: vi.fn(),
42
+ openZenMode: vi.fn(),
43
+ closeZenMode: vi.fn()
44
44
  }
45
45
  });
46
46
  describe('MarkdownToolbar', ()=>{
47
47
  beforeEach(()=>{
48
- jest.clearAllMocks();
48
+ vi.clearAllMocks();
49
49
  });
50
50
  it('opens the heading menu and calls the selected heading action', async ()=>{
51
51
  const props = createProps();
@@ -1,3 +1,4 @@
1
+ import { describe, expect, it } from 'vitest';
1
2
  import { replaceAssetDomain } from './insertAssetLinks';
2
3
  describe('replaceAssetDomain', ()=>{
3
4
  it('should replace contentful.com domains to ctfassets.net', ()=>{
@@ -1,3 +1,4 @@
1
+ import { describe, expect, it } from 'vitest';
1
2
  import * as LinkOrganizer from './linkOrganizer';
2
3
  describe('Link organizer', ()=>{
3
4
  describe('Inline link finder', ()=>{
@@ -1,3 +1,4 @@
1
+ import { describe, expect, test } from 'vitest';
1
2
  import { replaceMailtoAmp } from './replaceMailtoAmp';
2
3
  describe('replace inside mailto', ()=>{
3
4
  let str = '<a href="mailto:example@example.com?subject=Hello&amp;body=Hello%20world">Send Email</a>';
@@ -1 +1 @@
1
- import '@testing-library/jest-dom/extend-expect';
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/field-editor-markdown",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "types": "dist/types/index.d.ts",
@@ -31,15 +31,15 @@
31
31
  "build:types": "tsc --outDir dist/types --emitDeclarationOnly",
32
32
  "build:cjs": "swc src --config-file ../../.swcrc -d dist/cjs -C module.type=commonjs",
33
33
  "build:esm": "swc src --config-file ../../.swcrc -d dist/esm",
34
- "test": "jest --watch",
35
- "test:ci": "jest --ci",
34
+ "test": "vitest",
35
+ "test:ci": "vitest run",
36
36
  "tsc": "tsc -p ./ --noEmit"
37
37
  },
38
38
  "dependencies": {
39
39
  "@contentful/f36-components": "^6.7.1",
40
40
  "@contentful/f36-icons": "^6.7.1",
41
41
  "@contentful/f36-tokens": "^6.1.2",
42
- "@contentful/field-editor-shared": "^4.4.0",
42
+ "@contentful/field-editor-shared": "^4.4.1",
43
43
  "@emotion/css": "^11.13.5",
44
44
  "@types/codemirror": "0.0.109",
45
45
  "codemirror": "^5.65.11",
@@ -52,7 +52,7 @@
52
52
  "devDependencies": {
53
53
  "@babel/core": "^7.5.5",
54
54
  "@contentful/app-sdk": "^4.29.0",
55
- "@contentful/field-editor-test-utils": "^3.1.0",
55
+ "@contentful/field-editor-test-utils": "^3.1.1",
56
56
  "@lingui/core": "5.3.0",
57
57
  "@testing-library/user-event": "^13.1.9"
58
58
  },
@@ -65,5 +65,5 @@
65
65
  "publishConfig": {
66
66
  "registry": "https://npm.pkg.github.com/"
67
67
  },
68
- "gitHead": "b3a1d791df55536d6de78bb138b97224d6c0c70e"
68
+ "gitHead": "5fb6c32d2590e72e56a53cb180a155f84d6505d9"
69
69
  }