@atlaskit/editor-core 150.0.3 → 151.0.0
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.
- package/CHANGELOG.md +47 -0
- package/dist/cjs/actions/index.js +5 -23
- package/dist/cjs/create-editor/ErrorBoundary.js +113 -79
- package/dist/cjs/create-editor/ReactEditorView.js +145 -31
- package/dist/cjs/create-editor/create-plugins-list.js +4 -2
- package/dist/cjs/editor.js +101 -40
- package/dist/cjs/labs/next/presets/cxhtml.js +2 -1
- package/dist/cjs/plugins/analytics/types/enums.js +3 -1
- package/dist/cjs/plugins/base/index.js +4 -3
- package/dist/cjs/plugins/base/pm-plugins/frozen-editor.js +66 -36
- package/dist/cjs/plugins/block-type/ui/ToolbarBlockType/styled.js +3 -1
- package/dist/cjs/plugins/card/index.js +13 -2
- package/dist/cjs/plugins/card/nodeviews/embedCard.js +1 -0
- package/dist/cjs/plugins/card/pm-plugins/main.js +7 -2
- package/dist/cjs/plugins/card/pm-plugins/util/resolve.js +10 -3
- package/dist/cjs/plugins/code-block/toolbar.js +1 -1
- package/dist/cjs/plugins/emoji/styles.js +1 -1
- package/dist/cjs/plugins/extension/pm-plugins/main.js +1 -4
- package/dist/cjs/plugins/extension/toolbar.js +28 -23
- package/dist/cjs/plugins/feature-flags-context/feature-flags-from-props.js +8 -3
- package/dist/cjs/plugins/find-replace/ui/Find.js +27 -7
- package/dist/cjs/plugins/hyperlink/pm-plugins/keymap.js +3 -3
- package/dist/cjs/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.js +7 -4
- package/dist/cjs/plugins/hyperlink/utils.js +6 -69
- package/dist/cjs/plugins/media/index.js +14 -3
- package/dist/cjs/plugins/media/nodeviews/mediaGroup.js +24 -10
- package/dist/cjs/plugins/media/nodeviews/mediaInline.js +179 -0
- package/dist/cjs/plugins/media/pm-plugins/main.js +18 -9
- package/dist/cjs/plugins/media/toolbar/index.js +49 -17
- package/dist/cjs/plugins/media/toolbar/utils.js +20 -2
- package/dist/cjs/plugins/media/utils/media-files.js +67 -1
- package/dist/cjs/plugins/panel/index.js +2 -3
- package/dist/cjs/plugins/panel/message.js +47 -0
- package/dist/cjs/plugins/panel/toolbar.js +64 -84
- package/dist/cjs/plugins/panel/utils.js +2 -2
- package/dist/cjs/plugins/paste/linkify-md-plugin.js +3 -3
- package/dist/cjs/plugins/status/styles.js +1 -1
- package/dist/cjs/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +18 -2
- package/dist/cjs/profiler/render-count.js +82 -0
- package/dist/cjs/ui/Appearance/Comment/Comment.js +6 -5
- package/dist/cjs/utils/react-hooks/use-component-renderer-tracking/index.js +55 -19
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/actions/index.js +6 -28
- package/dist/es2019/create-editor/ErrorBoundary.js +73 -60
- package/dist/es2019/create-editor/ReactEditorView.js +130 -23
- package/dist/es2019/create-editor/create-plugins-list.js +4 -2
- package/dist/es2019/editor.js +74 -35
- package/dist/es2019/labs/next/presets/cxhtml.js +2 -1
- package/dist/es2019/plugins/analytics/types/enums.js +3 -1
- package/dist/es2019/plugins/base/index.js +4 -3
- package/dist/es2019/plugins/base/pm-plugins/frozen-editor.js +63 -35
- package/dist/es2019/plugins/block-type/ui/ToolbarBlockType/styled.js +2 -1
- package/dist/es2019/plugins/card/index.js +7 -2
- package/dist/es2019/plugins/card/nodeviews/embedCard.js +1 -0
- package/dist/es2019/plugins/card/pm-plugins/main.js +9 -2
- package/dist/es2019/plugins/card/pm-plugins/util/resolve.js +12 -5
- package/dist/es2019/plugins/code-block/toolbar.js +1 -1
- package/dist/es2019/plugins/emoji/styles.js +2 -0
- package/dist/es2019/plugins/extension/pm-plugins/main.js +1 -4
- package/dist/es2019/plugins/extension/toolbar.js +30 -25
- package/dist/es2019/plugins/feature-flags-context/feature-flags-from-props.js +8 -4
- package/dist/es2019/plugins/find-replace/ui/Find.js +27 -6
- package/dist/es2019/plugins/hyperlink/pm-plugins/keymap.js +1 -1
- package/dist/es2019/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.js +7 -4
- package/dist/es2019/plugins/hyperlink/utils.js +3 -59
- package/dist/es2019/plugins/media/index.js +13 -4
- package/dist/es2019/plugins/media/nodeviews/mediaGroup.js +16 -7
- package/dist/es2019/plugins/media/nodeviews/mediaInline.js +88 -0
- package/dist/es2019/plugins/media/pm-plugins/main.js +20 -11
- package/dist/es2019/plugins/media/toolbar/index.js +44 -15
- package/dist/es2019/plugins/media/toolbar/utils.js +16 -0
- package/dist/es2019/plugins/media/utils/media-files.js +68 -2
- package/dist/es2019/plugins/panel/index.js +3 -4
- package/dist/es2019/plugins/panel/message.js +38 -0
- package/dist/es2019/plugins/panel/toolbar.js +52 -71
- package/dist/es2019/plugins/panel/utils.js +2 -2
- package/dist/es2019/plugins/paste/linkify-md-plugin.js +2 -2
- package/dist/es2019/plugins/status/styles.js +2 -0
- package/dist/es2019/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +18 -2
- package/dist/es2019/profiler/render-count.js +60 -0
- package/dist/es2019/ui/Appearance/Comment/Comment.js +4 -2
- package/dist/es2019/utils/react-hooks/use-component-renderer-tracking/index.js +51 -18
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/actions/index.js +6 -24
- package/dist/esm/create-editor/ErrorBoundary.js +113 -78
- package/dist/esm/create-editor/ReactEditorView.js +146 -31
- package/dist/esm/create-editor/create-plugins-list.js +4 -2
- package/dist/esm/editor.js +100 -40
- package/dist/esm/labs/next/presets/cxhtml.js +2 -1
- package/dist/esm/plugins/analytics/types/enums.js +3 -1
- package/dist/esm/plugins/base/index.js +4 -3
- package/dist/esm/plugins/base/pm-plugins/frozen-editor.js +64 -36
- package/dist/esm/plugins/block-type/ui/ToolbarBlockType/styled.js +3 -1
- package/dist/esm/plugins/card/index.js +13 -2
- package/dist/esm/plugins/card/nodeviews/embedCard.js +1 -0
- package/dist/esm/plugins/card/pm-plugins/main.js +7 -2
- package/dist/esm/plugins/card/pm-plugins/util/resolve.js +12 -5
- package/dist/esm/plugins/code-block/toolbar.js +1 -1
- package/dist/esm/plugins/emoji/styles.js +1 -1
- package/dist/esm/plugins/extension/pm-plugins/main.js +1 -4
- package/dist/esm/plugins/extension/toolbar.js +28 -23
- package/dist/esm/plugins/feature-flags-context/feature-flags-from-props.js +8 -4
- package/dist/esm/plugins/find-replace/ui/Find.js +27 -7
- package/dist/esm/plugins/hyperlink/pm-plugins/keymap.js +1 -1
- package/dist/esm/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.js +7 -4
- package/dist/esm/plugins/hyperlink/utils.js +3 -59
- package/dist/esm/plugins/media/index.js +14 -4
- package/dist/esm/plugins/media/nodeviews/mediaGroup.js +24 -10
- package/dist/esm/plugins/media/nodeviews/mediaInline.js +147 -0
- package/dist/esm/plugins/media/pm-plugins/main.js +19 -11
- package/dist/esm/plugins/media/toolbar/index.js +47 -19
- package/dist/esm/plugins/media/toolbar/utils.js +15 -1
- package/dist/esm/plugins/media/utils/media-files.js +60 -2
- package/dist/esm/plugins/panel/index.js +3 -4
- package/dist/esm/plugins/panel/message.js +38 -0
- package/dist/esm/plugins/panel/toolbar.js +57 -77
- package/dist/esm/plugins/panel/utils.js +2 -2
- package/dist/esm/plugins/paste/linkify-md-plugin.js +2 -2
- package/dist/esm/plugins/status/styles.js +1 -1
- package/dist/esm/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +18 -2
- package/dist/esm/profiler/render-count.js +57 -0
- package/dist/esm/ui/Appearance/Comment/Comment.js +6 -5
- package/dist/esm/utils/react-hooks/use-component-renderer-tracking/index.js +53 -20
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/create-editor/ErrorBoundary.d.ts +6 -6
- package/dist/types/create-editor/ReactEditorView.d.ts +15 -3
- package/dist/types/editor.d.ts +2 -0
- package/dist/types/plugins/analytics/index.d.ts +1 -1
- package/dist/types/plugins/analytics/types/enums.d.ts +4 -2
- package/dist/types/plugins/analytics/types/events.d.ts +7 -2
- package/dist/types/plugins/analytics/types/general-events.d.ts +4 -1
- package/dist/types/plugins/analytics/types/index.d.ts +1 -1
- package/dist/types/plugins/analytics/types/insert-events.d.ts +6 -1
- package/dist/types/plugins/analytics/types/link-tool-bar-events.d.ts +1 -0
- package/dist/types/plugins/base/index.d.ts +1 -0
- package/dist/types/plugins/base/pm-plugins/frozen-editor.d.ts +3 -2
- package/dist/types/plugins/card/pm-plugins/main.d.ts +2 -3
- package/dist/types/plugins/card/pm-plugins/util/resolve.d.ts +2 -1
- package/dist/types/plugins/card/types.d.ts +6 -0
- package/dist/types/plugins/extension/types.d.ts +0 -2
- package/dist/types/plugins/feature-flags-context/get-enabled-feature-flag-keys.d.ts +1 -1
- package/dist/types/plugins/floating-toolbar/types.d.ts +1 -1
- package/dist/types/plugins/floating-toolbar/ui/Select.d.ts +1 -1
- package/dist/types/plugins/hyperlink/utils.d.ts +0 -21
- package/dist/types/plugins/media/nodeviews/mediaInline.d.ts +27 -0
- package/dist/types/plugins/media/pm-plugins/main.d.ts +2 -2
- package/dist/types/plugins/media/toolbar/utils.d.ts +2 -0
- package/dist/types/plugins/media/utils/media-files.d.ts +8 -0
- package/dist/types/plugins/panel/message.d.ts +37 -0
- package/dist/types/plugins/panel/toolbar.d.ts +4 -37
- package/dist/types/plugins/panel/types.d.ts +1 -0
- package/dist/types/profiler/render-count.d.ts +14 -0
- package/dist/types/types/feature-flags.d.ts +8 -0
- package/dist/types/ui/LinkSearch/types.d.ts +1 -0
- package/dist/types/utils/react-hooks/use-component-renderer-tracking/index.d.ts +17 -1
- package/package.json +19 -16
- package/dist/cjs/plugins/caption/nodeviews/index.test.js +0 -135
- package/dist/cjs/plugins/caption/pm-plugins/keymap.test.js +0 -203
- package/dist/cjs/plugins/caption/pm-plugins/main.test.js +0 -141
- package/dist/cjs/plugins/code-block/language-list.test.js +0 -74
- package/dist/cjs/plugins/extension/ui/SaveIndicator/SaveIndicator.test.js +0 -101
- package/dist/cjs/plugins/floating-toolbar/ui/EmojiPickerButton.test.js +0 -98
- package/dist/cjs/plugins/media/commands/captions.test.js +0 -149
- package/dist/cjs/plugins/media/commands/linking.test.js +0 -296
- package/dist/cjs/plugins/media/ui/CaptionPlaceholder/index.test.js +0 -50
- package/dist/cjs/plugins/panel/toolbar.test.js +0 -250
- package/dist/cjs/ui/ColorPickerButton/index.test.js +0 -123
- package/dist/cjs/ui/PortalProvider/index.test.js +0 -139
- package/dist/es2019/plugins/caption/nodeviews/index.test.js +0 -122
- package/dist/es2019/plugins/caption/pm-plugins/keymap.test.js +0 -193
- package/dist/es2019/plugins/caption/pm-plugins/main.test.js +0 -132
- package/dist/es2019/plugins/code-block/language-list.test.js +0 -69
- package/dist/es2019/plugins/extension/ui/SaveIndicator/SaveIndicator.test.js +0 -83
- package/dist/es2019/plugins/floating-toolbar/ui/EmojiPickerButton.test.js +0 -85
- package/dist/es2019/plugins/media/commands/captions.test.js +0 -126
- package/dist/es2019/plugins/media/commands/linking.test.js +0 -208
- package/dist/es2019/plugins/media/ui/CaptionPlaceholder/index.test.js +0 -41
- package/dist/es2019/plugins/panel/toolbar.test.js +0 -200
- package/dist/es2019/ui/ColorPickerButton/index.test.js +0 -88
- package/dist/es2019/ui/PortalProvider/index.test.js +0 -115
- package/dist/esm/plugins/caption/nodeviews/index.test.js +0 -125
- package/dist/esm/plugins/caption/pm-plugins/keymap.test.js +0 -195
- package/dist/esm/plugins/caption/pm-plugins/main.test.js +0 -124
- package/dist/esm/plugins/code-block/language-list.test.js +0 -71
- package/dist/esm/plugins/extension/ui/SaveIndicator/SaveIndicator.test.js +0 -92
- package/dist/esm/plugins/floating-toolbar/ui/EmojiPickerButton.test.js +0 -85
- package/dist/esm/plugins/media/commands/captions.test.js +0 -135
- package/dist/esm/plugins/media/commands/linking.test.js +0 -268
- package/dist/esm/plugins/media/ui/CaptionPlaceholder/index.test.js +0 -41
- package/dist/esm/plugins/panel/toolbar.test.js +0 -230
- package/dist/esm/ui/ColorPickerButton/index.test.js +0 -107
- package/dist/esm/ui/PortalProvider/index.test.js +0 -129
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import { createEditorFactory } from '@atlaskit/editor-test-helpers/create-editor';
|
|
2
|
-
import { caption, doc, media, mediaSingle, p } from '@atlaskit/editor-test-helpers/doc-builder';
|
|
3
|
-
import { setNodeSelection, setTextSelection } from '../../../utils';
|
|
4
|
-
import { render } from '@testing-library/react';
|
|
5
|
-
import { getSchemaBasedOnStage } from '@atlaskit/adf-schema';
|
|
6
|
-
import captionNodeView from '.';
|
|
7
|
-
jest.mock('../../base/pm-plugins/react-nodeview', function () {
|
|
8
|
-
return {
|
|
9
|
-
stateKey: {
|
|
10
|
-
getState: function getState() {
|
|
11
|
-
return {
|
|
12
|
-
subscribe: jest.fn(),
|
|
13
|
-
unsubscribe: jest.fn()
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
});
|
|
19
|
-
var createEditorTestingLibrary = createEditorFactory(render);
|
|
20
|
-
|
|
21
|
-
var editor = function editor(doc) {
|
|
22
|
-
return createEditorTestingLibrary({
|
|
23
|
-
doc: doc,
|
|
24
|
-
editorProps: {
|
|
25
|
-
media: {
|
|
26
|
-
allowMediaSingle: true,
|
|
27
|
-
featureFlags: {
|
|
28
|
-
captions: true
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
var mediaNodeAttrs = {
|
|
36
|
-
id: 'a559980d-cd47-43e2-8377-27359fcb905f',
|
|
37
|
-
type: 'file',
|
|
38
|
-
collection: 'MediaServicesSample',
|
|
39
|
-
width: 250,
|
|
40
|
-
height: 250
|
|
41
|
-
};
|
|
42
|
-
describe('caption', function () {
|
|
43
|
-
it('should render caption children', function () {
|
|
44
|
-
var CAPTION_TEXT = 'this is a very cool caption';
|
|
45
|
-
|
|
46
|
-
var _editor = editor(doc(mediaSingle()(media(mediaNodeAttrs)(), caption(CAPTION_TEXT)))),
|
|
47
|
-
getByText = _editor.wrapper.getByText;
|
|
48
|
-
|
|
49
|
-
expect(getByText(CAPTION_TEXT)).not.toBeNull();
|
|
50
|
-
});
|
|
51
|
-
it("should show a placeholder if there's no children", function () {
|
|
52
|
-
var _editor2 = editor(doc('{<node>}', // node selection
|
|
53
|
-
mediaSingle()(media(mediaNodeAttrs)()))),
|
|
54
|
-
getByText = _editor2.wrapper.getByText;
|
|
55
|
-
|
|
56
|
-
expect(getByText('Add a caption')).not.toBeNull();
|
|
57
|
-
});
|
|
58
|
-
it('should not show a placeholder when selecting away from media single', function () {
|
|
59
|
-
var _editor3 = editor(doc('{<node>}', // node selection
|
|
60
|
-
mediaSingle()(media(mediaNodeAttrs)()), p('this is a random piece of text'))),
|
|
61
|
-
_editor3$wrapper = _editor3.wrapper,
|
|
62
|
-
queryByText = _editor3$wrapper.queryByText,
|
|
63
|
-
getByText = _editor3$wrapper.getByText,
|
|
64
|
-
editorView = _editor3.editorView;
|
|
65
|
-
|
|
66
|
-
expect(getByText('Add a caption')).not.toBeNull();
|
|
67
|
-
setTextSelection(editorView, 13, 14);
|
|
68
|
-
expect(queryByText('Add a caption')).toBeNull();
|
|
69
|
-
});
|
|
70
|
-
it('should show a placeholder when selecting a media single', function () {
|
|
71
|
-
var _editor4 = editor(doc('{node}', // node selection
|
|
72
|
-
mediaSingle()(media(mediaNodeAttrs)()), p('this is a random p{<>}iece of text'))),
|
|
73
|
-
_editor4$wrapper = _editor4.wrapper,
|
|
74
|
-
queryByText = _editor4$wrapper.queryByText,
|
|
75
|
-
getByText = _editor4$wrapper.getByText,
|
|
76
|
-
editorView = _editor4.editorView;
|
|
77
|
-
|
|
78
|
-
expect(queryByText('Add a caption')).toBeNull();
|
|
79
|
-
setNodeSelection(editorView, 0);
|
|
80
|
-
expect(getByText('Add a caption')).not.toBeNull();
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
describe('nodeview updating based on child count', function () {
|
|
84
|
-
var portalProviderAPI = {
|
|
85
|
-
render: function render(component) {
|
|
86
|
-
component();
|
|
87
|
-
},
|
|
88
|
-
remove: function remove() {}
|
|
89
|
-
};
|
|
90
|
-
var eventDispatcher = {};
|
|
91
|
-
var node = caption('hi')(getSchemaBasedOnStage('stage0'));
|
|
92
|
-
var view = {
|
|
93
|
-
state: {
|
|
94
|
-
selection: {
|
|
95
|
-
from: 0,
|
|
96
|
-
to: 0,
|
|
97
|
-
$anchor: {
|
|
98
|
-
pos: 0
|
|
99
|
-
},
|
|
100
|
-
$head: {
|
|
101
|
-
pos: 20
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
var getPos = jest.fn();
|
|
107
|
-
it('does not update if the childCount has not changed', function () {
|
|
108
|
-
var nodeView = captionNodeView(portalProviderAPI, eventDispatcher)(node, view, getPos); // ensure that if it falls through to the default it returns false
|
|
109
|
-
|
|
110
|
-
nodeView['_viewShouldUpdate'] = jest.fn(function (_node) {
|
|
111
|
-
return false;
|
|
112
|
-
});
|
|
113
|
-
expect(nodeView.viewShouldUpdate(node)).toBeFalsy();
|
|
114
|
-
});
|
|
115
|
-
it('updates if the childCount has changed', function () {
|
|
116
|
-
var nodeView = captionNodeView(portalProviderAPI, eventDispatcher)(node, view, getPos); // when captions is in full schema, use defaultSchema
|
|
117
|
-
|
|
118
|
-
var newNode = caption()(getSchemaBasedOnStage('stage0')); // ensure that if it falls through to the default it returns false
|
|
119
|
-
|
|
120
|
-
nodeView['_viewShouldUpdate'] = jest.fn(function (_node) {
|
|
121
|
-
return false;
|
|
122
|
-
});
|
|
123
|
-
expect(nodeView.viewShouldUpdate(newNode)).toBeTruthy();
|
|
124
|
-
});
|
|
125
|
-
});
|
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
import { sendKeyToPm } from '@atlaskit/editor-test-helpers/send-key-to-pm';
|
|
2
|
-
import { createEditorFactory } from '@atlaskit/editor-test-helpers/create-editor';
|
|
3
|
-
import { caption, doc, media, mediaSingle, p, panel } from '@atlaskit/editor-test-helpers/doc-builder';
|
|
4
|
-
import { NodeSelection, TextSelection } from 'prosemirror-state';
|
|
5
|
-
import { findParentNodeOfType } from 'prosemirror-utils';
|
|
6
|
-
import { GapCursorSelection } from '../../selection/gap-cursor/selection';
|
|
7
|
-
var createEditorTestingLibrary = createEditorFactory();
|
|
8
|
-
|
|
9
|
-
var editor = function editor(doc) {
|
|
10
|
-
return createEditorTestingLibrary({
|
|
11
|
-
doc: doc,
|
|
12
|
-
editorProps: {
|
|
13
|
-
allowPanel: true,
|
|
14
|
-
media: {
|
|
15
|
-
allowMediaSingle: true,
|
|
16
|
-
featureFlags: {
|
|
17
|
-
captions: true
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
describe('caption keymap', function () {
|
|
25
|
-
it('should go to caption on tab', function () {
|
|
26
|
-
var _editor = editor(doc('{<node>}', mediaSingle()(media({
|
|
27
|
-
id: 'a559980d-cd47-43e2-8377-27359fcb905f',
|
|
28
|
-
type: 'file',
|
|
29
|
-
collection: 'MediaServicesSample'
|
|
30
|
-
})(), caption('Hello')))),
|
|
31
|
-
editorView = _editor.editorView;
|
|
32
|
-
|
|
33
|
-
sendKeyToPm(editorView, 'Tab');
|
|
34
|
-
var captionParentNode = findParentNodeOfType(editorView.state.schema.nodes.caption)(editorView.state.selection);
|
|
35
|
-
expect(editorView.state.selection instanceof TextSelection).toBe(true);
|
|
36
|
-
expect(captionParentNode).toBeDefined();
|
|
37
|
-
});
|
|
38
|
-
it('should select caption on arrow down', function () {
|
|
39
|
-
var _editor2 = editor(doc('{<node>}', mediaSingle()(media({
|
|
40
|
-
id: 'a559980d-cd47-43e2-8377-27359fcb905f',
|
|
41
|
-
type: 'file',
|
|
42
|
-
collection: 'MediaServicesSample'
|
|
43
|
-
})(), caption('Hello')), p(''))),
|
|
44
|
-
editorView = _editor2.editorView;
|
|
45
|
-
|
|
46
|
-
sendKeyToPm(editorView, 'ArrowDown');
|
|
47
|
-
var captionParentNode = findParentNodeOfType(editorView.state.schema.nodes.caption)(editorView.state.selection);
|
|
48
|
-
expect(editorView.state.selection instanceof TextSelection).toBe(true);
|
|
49
|
-
expect(captionParentNode).toBeDefined();
|
|
50
|
-
});
|
|
51
|
-
it('should select media from paragraph below on arrow up', function () {
|
|
52
|
-
var _editor3 = editor(doc(mediaSingle({
|
|
53
|
-
layout: 'center'
|
|
54
|
-
})(media({
|
|
55
|
-
id: 'abc',
|
|
56
|
-
type: 'file',
|
|
57
|
-
collection: 'xyz'
|
|
58
|
-
})(), caption('hello')), p('{<>}something'))),
|
|
59
|
-
editorView = _editor3.editorView;
|
|
60
|
-
|
|
61
|
-
sendKeyToPm(editorView, 'ArrowUp');
|
|
62
|
-
expect(editorView.state.selection instanceof NodeSelection).toBe(true);
|
|
63
|
-
expect(editorView.state.selection.from).toBe(0);
|
|
64
|
-
});
|
|
65
|
-
it('should select media from caption on arrow up', function () {
|
|
66
|
-
var _editor4 = editor(doc(mediaSingle({
|
|
67
|
-
layout: 'center'
|
|
68
|
-
})(media({
|
|
69
|
-
id: 'abc',
|
|
70
|
-
type: 'file',
|
|
71
|
-
collection: 'xyz'
|
|
72
|
-
})(), caption('he{<>}llo')), p('something'))),
|
|
73
|
-
editorView = _editor4.editorView;
|
|
74
|
-
|
|
75
|
-
sendKeyToPm(editorView, 'ArrowUp');
|
|
76
|
-
expect(editorView.state.selection instanceof NodeSelection).toBe(true);
|
|
77
|
-
expect(editorView.state.selection.from).toBe(0);
|
|
78
|
-
});
|
|
79
|
-
it('should select media from caption on shift + tab', function () {
|
|
80
|
-
var _editor5 = editor(doc(mediaSingle({
|
|
81
|
-
layout: 'center'
|
|
82
|
-
})(media({
|
|
83
|
-
id: 'abc',
|
|
84
|
-
type: 'file',
|
|
85
|
-
collection: 'xyz'
|
|
86
|
-
})(), caption('he{<>}llo')), p('something'))),
|
|
87
|
-
editorView = _editor5.editorView;
|
|
88
|
-
|
|
89
|
-
sendKeyToPm(editorView, 'Shift-Tab');
|
|
90
|
-
expect(editorView.state.selection instanceof NodeSelection).toBe(true);
|
|
91
|
-
expect(editorView.state.selection.from).toBe(0);
|
|
92
|
-
});
|
|
93
|
-
it('should create paragraph below caption on arrow down', function () {
|
|
94
|
-
var _editor6 = editor(doc(mediaSingle({
|
|
95
|
-
layout: 'center'
|
|
96
|
-
})(media({
|
|
97
|
-
id: 'a559980d-cd47-43e2-8377-27359fcb905f',
|
|
98
|
-
type: 'file',
|
|
99
|
-
collection: 'MediaServicesSample'
|
|
100
|
-
})(), caption('hello{<>}')))),
|
|
101
|
-
editorView = _editor6.editorView;
|
|
102
|
-
|
|
103
|
-
sendKeyToPm(editorView, 'ArrowDown');
|
|
104
|
-
expect(editorView.state.doc).toEqualDocument(doc(mediaSingle()(media({
|
|
105
|
-
id: 'a559980d-cd47-43e2-8377-27359fcb905f',
|
|
106
|
-
type: 'file',
|
|
107
|
-
collection: 'MediaServicesSample'
|
|
108
|
-
})(), caption('hello')), p()));
|
|
109
|
-
});
|
|
110
|
-
it('should create paragraph below caption on enter', function () {
|
|
111
|
-
var _editor7 = editor(doc(mediaSingle({
|
|
112
|
-
layout: 'center'
|
|
113
|
-
})(media({
|
|
114
|
-
id: 'a559980d-cd47-43e2-8377-27359fcb905f',
|
|
115
|
-
type: 'file',
|
|
116
|
-
collection: 'MediaServicesSample'
|
|
117
|
-
})(), caption('hello{<>}')))),
|
|
118
|
-
editorView = _editor7.editorView;
|
|
119
|
-
|
|
120
|
-
sendKeyToPm(editorView, 'Enter');
|
|
121
|
-
expect(editorView.state.doc).toEqualDocument(doc(mediaSingle()(media({
|
|
122
|
-
id: 'a559980d-cd47-43e2-8377-27359fcb905f',
|
|
123
|
-
type: 'file',
|
|
124
|
-
collection: 'MediaServicesSample'
|
|
125
|
-
})(), caption('hello')), p()));
|
|
126
|
-
});
|
|
127
|
-
it('should not create paragraph below panel on enter', function () {
|
|
128
|
-
var _editor8 = editor(doc(panel()(p('text{<>}')))),
|
|
129
|
-
editorView = _editor8.editorView;
|
|
130
|
-
|
|
131
|
-
sendKeyToPm(editorView, 'Enter');
|
|
132
|
-
expect(editorView.state.doc).toEqualDocument(doc(panel()(p('text'), p())));
|
|
133
|
-
});
|
|
134
|
-
it('should move to paragraph below caption on arrow down', function () {
|
|
135
|
-
var _editor9 = editor(doc(mediaSingle({
|
|
136
|
-
layout: 'center'
|
|
137
|
-
})(media({
|
|
138
|
-
id: 'a559980d-cd47-43e2-8377-27359fcb905f',
|
|
139
|
-
type: 'file',
|
|
140
|
-
collection: 'MediaServicesSample'
|
|
141
|
-
})(), caption('hel{<>}lo')), p('something'))),
|
|
142
|
-
editorView = _editor9.editorView;
|
|
143
|
-
|
|
144
|
-
sendKeyToPm(editorView, 'ArrowDown');
|
|
145
|
-
expect(editorView.state).toEqualDocumentAndSelection(doc(mediaSingle()(media({
|
|
146
|
-
id: 'a559980d-cd47-43e2-8377-27359fcb905f',
|
|
147
|
-
type: 'file',
|
|
148
|
-
collection: 'MediaServicesSample'
|
|
149
|
-
})(), caption('hello')), p('{<>}something')));
|
|
150
|
-
});
|
|
151
|
-
it('should move to paragraph below caption on enter', function () {
|
|
152
|
-
var _editor10 = editor(doc(mediaSingle({
|
|
153
|
-
layout: 'center'
|
|
154
|
-
})(media({
|
|
155
|
-
id: 'a559980d-cd47-43e2-8377-27359fcb905f',
|
|
156
|
-
type: 'file',
|
|
157
|
-
collection: 'MediaServicesSample'
|
|
158
|
-
})(), caption('he{<>}llo')), p('something'))),
|
|
159
|
-
editorView = _editor10.editorView;
|
|
160
|
-
|
|
161
|
-
sendKeyToPm(editorView, 'Enter');
|
|
162
|
-
expect(editorView.state).toEqualDocumentAndSelection(doc(mediaSingle()(media({
|
|
163
|
-
id: 'a559980d-cd47-43e2-8377-27359fcb905f',
|
|
164
|
-
type: 'file',
|
|
165
|
-
collection: 'MediaServicesSample'
|
|
166
|
-
})(), caption('hello')), p('{<>}something')));
|
|
167
|
-
});
|
|
168
|
-
it('should gap cursor parent media single on left arrow', function () {
|
|
169
|
-
var _editor11 = editor(doc(mediaSingle()(media({
|
|
170
|
-
id: 'a559980d-cd47-43e2-8377-27359fcb905f',
|
|
171
|
-
type: 'file',
|
|
172
|
-
collection: 'MediaServicesSample'
|
|
173
|
-
})(), caption('{<>}Hello')), p(''))),
|
|
174
|
-
editorView = _editor11.editorView;
|
|
175
|
-
|
|
176
|
-
sendKeyToPm(editorView, 'ArrowLeft');
|
|
177
|
-
expect(editorView.state.selection).toBeInstanceOf(GapCursorSelection);
|
|
178
|
-
expect(editorView.state).toEqualDocumentAndSelection(doc('{<gap|>}', mediaSingle()(media({
|
|
179
|
-
id: 'a559980d-cd47-43e2-8377-27359fcb905f',
|
|
180
|
-
type: 'file',
|
|
181
|
-
collection: 'MediaServicesSample'
|
|
182
|
-
})(), caption('Hello')), p('')));
|
|
183
|
-
});
|
|
184
|
-
it('should not gap cursor parent media single on left arrow when not at start', function () {
|
|
185
|
-
var _editor12 = editor(doc(mediaSingle()(media({
|
|
186
|
-
id: 'a559980d-cd47-43e2-8377-27359fcb905f',
|
|
187
|
-
type: 'file',
|
|
188
|
-
collection: 'MediaServicesSample'
|
|
189
|
-
})(), caption('H{<>}ello')), p(''))),
|
|
190
|
-
editorView = _editor12.editorView;
|
|
191
|
-
|
|
192
|
-
sendKeyToPm(editorView, 'ArrowLeft');
|
|
193
|
-
expect(editorView.state.selection).not.toBeInstanceOf(GapCursorSelection);
|
|
194
|
-
});
|
|
195
|
-
});
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import { createProsemirrorEditorFactory, Preset } from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
|
|
2
|
-
import mediaPlugin from '../../media';
|
|
3
|
-
import captionPlugin from '../';
|
|
4
|
-
import { caption, doc, media, mediaSingle, p } from '@atlaskit/editor-test-helpers/doc-builder';
|
|
5
|
-
import { pluginKey } from './plugin-key';
|
|
6
|
-
import { setTextSelection } from '../../../utils/selection';
|
|
7
|
-
import * as analyticsUtils from '../../analytics/utils';
|
|
8
|
-
describe('Caption plugin', function () {
|
|
9
|
-
var createEditor = createProsemirrorEditorFactory();
|
|
10
|
-
|
|
11
|
-
var editor = function editor(doc) {
|
|
12
|
-
return createEditor({
|
|
13
|
-
doc: doc,
|
|
14
|
-
pluginKey: pluginKey,
|
|
15
|
-
preset: new Preset().add([mediaPlugin, {
|
|
16
|
-
allowMediaSingle: true,
|
|
17
|
-
featureFlags: {
|
|
18
|
-
captions: true
|
|
19
|
-
}
|
|
20
|
-
}]).add(captionPlugin)
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
it('should not remove caption when there is content', function () {
|
|
25
|
-
var _editor = editor(doc(mediaSingle()(media({
|
|
26
|
-
id: 'a559980d-cd47-43e2-8377-27359fcb905f',
|
|
27
|
-
type: 'file',
|
|
28
|
-
collection: 'MediaServicesSample'
|
|
29
|
-
})(), caption('Test{<>}')), p('Line {movePos}two'))),
|
|
30
|
-
editorView = _editor.editorView,
|
|
31
|
-
movePos = _editor.refs.movePos;
|
|
32
|
-
|
|
33
|
-
setTextSelection(editorView, movePos);
|
|
34
|
-
expect(editorView.state.doc).toEqualDocument(doc(mediaSingle()(media({
|
|
35
|
-
id: 'a559980d-cd47-43e2-8377-27359fcb905f',
|
|
36
|
-
type: 'file',
|
|
37
|
-
collection: 'MediaServicesSample'
|
|
38
|
-
})(), caption('Test')), p('Line two')));
|
|
39
|
-
});
|
|
40
|
-
it('should remove caption when there is no content', function () {
|
|
41
|
-
var _editor2 = editor(doc(mediaSingle()(media({
|
|
42
|
-
id: 'a559980d-cd47-43e2-8377-27359fcb905f',
|
|
43
|
-
type: 'file',
|
|
44
|
-
collection: 'MediaServicesSample'
|
|
45
|
-
})(), caption('{<>}')), p('Line {movePos}two'))),
|
|
46
|
-
editorView = _editor2.editorView,
|
|
47
|
-
movePos = _editor2.refs.movePos;
|
|
48
|
-
|
|
49
|
-
setTextSelection(editorView, movePos);
|
|
50
|
-
expect(editorView.state.doc).toEqualDocument(doc(mediaSingle()(media({
|
|
51
|
-
id: 'a559980d-cd47-43e2-8377-27359fcb905f',
|
|
52
|
-
type: 'file',
|
|
53
|
-
collection: 'MediaServicesSample'
|
|
54
|
-
})()), p('Line two')));
|
|
55
|
-
});
|
|
56
|
-
it('should remove caption when clicking onto another caption', function () {
|
|
57
|
-
var _editor3 = editor(doc(mediaSingle()(media({
|
|
58
|
-
id: 'a559980d-cd47-43e2-8377-27359fcb905f',
|
|
59
|
-
type: 'file',
|
|
60
|
-
collection: 'MediaServicesSample'
|
|
61
|
-
})(), caption('{<>}')), mediaSingle()(media({
|
|
62
|
-
id: 'a559980d-cd47-43e2-8377-27359fcb905f',
|
|
63
|
-
type: 'file',
|
|
64
|
-
collection: 'MediaServicesSample'
|
|
65
|
-
})(), caption('second {movePos}caption')))),
|
|
66
|
-
editorView = _editor3.editorView,
|
|
67
|
-
movePos = _editor3.refs.movePos;
|
|
68
|
-
|
|
69
|
-
setTextSelection(editorView, movePos);
|
|
70
|
-
expect(editorView.state.doc).toEqualDocument(doc(mediaSingle()(media({
|
|
71
|
-
id: 'a559980d-cd47-43e2-8377-27359fcb905f',
|
|
72
|
-
type: 'file',
|
|
73
|
-
collection: 'MediaServicesSample'
|
|
74
|
-
})()), mediaSingle()(media({
|
|
75
|
-
id: 'a559980d-cd47-43e2-8377-27359fcb905f',
|
|
76
|
-
type: 'file',
|
|
77
|
-
collection: 'MediaServicesSample'
|
|
78
|
-
})(), caption('second caption'))));
|
|
79
|
-
});
|
|
80
|
-
describe('analytics', function () {
|
|
81
|
-
var addAnalyticsSpy = jest.spyOn(analyticsUtils, 'addAnalytics');
|
|
82
|
-
var FIRST_CALL = 0;
|
|
83
|
-
var PAYLOAD_ARGUMENT = 2;
|
|
84
|
-
beforeEach(function () {
|
|
85
|
-
addAnalyticsSpy.mockReset();
|
|
86
|
-
});
|
|
87
|
-
it('should fire deleted analytic when removing caption', function () {
|
|
88
|
-
var _editor4 = editor(doc(mediaSingle()(media({
|
|
89
|
-
id: 'a559980d-cd47-43e2-8377-27359fcb905f',
|
|
90
|
-
type: 'file',
|
|
91
|
-
collection: 'MediaServicesSample'
|
|
92
|
-
})(), caption('{<>}')), p('Line {movePos}two'))),
|
|
93
|
-
editorView = _editor4.editorView,
|
|
94
|
-
movePos = _editor4.refs.movePos;
|
|
95
|
-
|
|
96
|
-
setTextSelection(editorView, movePos);
|
|
97
|
-
expect(addAnalyticsSpy).toBeCalled();
|
|
98
|
-
expect(addAnalyticsSpy.mock.calls[FIRST_CALL][PAYLOAD_ARGUMENT]).toEqual({
|
|
99
|
-
action: 'deleted',
|
|
100
|
-
actionSubject: 'mediaSingle',
|
|
101
|
-
actionSubjectId: 'caption',
|
|
102
|
-
eventType: 'track'
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
it('should fire edited analytic when moving away from a non empty caption', function () {
|
|
106
|
-
var _editor5 = editor(doc(mediaSingle()(media({
|
|
107
|
-
id: 'a559980d-cd47-43e2-8377-27359fcb905f',
|
|
108
|
-
type: 'file',
|
|
109
|
-
collection: 'MediaServicesSample'
|
|
110
|
-
})(), caption('Test{<>}')), p('Line {movePos}two'))),
|
|
111
|
-
editorView = _editor5.editorView,
|
|
112
|
-
movePos = _editor5.refs.movePos;
|
|
113
|
-
|
|
114
|
-
setTextSelection(editorView, movePos);
|
|
115
|
-
expect(addAnalyticsSpy).toBeCalled();
|
|
116
|
-
expect(addAnalyticsSpy.mock.calls[FIRST_CALL][PAYLOAD_ARGUMENT]).toEqual({
|
|
117
|
-
action: 'edited',
|
|
118
|
-
actionSubject: 'mediaSingle',
|
|
119
|
-
actionSubjectId: 'caption',
|
|
120
|
-
eventType: 'track'
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
});
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { DEFAULT_LANGUAGES, findMatchedLanguage, filterSupportedLanguages, getLanguageIdentifier, createLanguageList } from './language-list';
|
|
2
|
-
var mockSupportedLanguages = [{
|
|
3
|
-
name: 'JSON',
|
|
4
|
-
alias: ['json'],
|
|
5
|
-
value: 'json'
|
|
6
|
-
}, {
|
|
7
|
-
name: 'JavaScript',
|
|
8
|
-
alias: ['javascript', 'js'],
|
|
9
|
-
value: 'javascript'
|
|
10
|
-
}, {
|
|
11
|
-
name: 'Python',
|
|
12
|
-
alias: ['python', 'py'],
|
|
13
|
-
value: 'python'
|
|
14
|
-
}];
|
|
15
|
-
describe('languageList utils', function () {
|
|
16
|
-
it('should find matched language', function () {
|
|
17
|
-
expect(findMatchedLanguage(mockSupportedLanguages, 'JavaScript')).toEqual({
|
|
18
|
-
name: 'JavaScript',
|
|
19
|
-
alias: ['javascript', 'js'],
|
|
20
|
-
value: 'javascript'
|
|
21
|
-
});
|
|
22
|
-
expect(findMatchedLanguage(mockSupportedLanguages, 'Python')).toEqual({
|
|
23
|
-
name: 'Python',
|
|
24
|
-
alias: ['python', 'py'],
|
|
25
|
-
value: 'python'
|
|
26
|
-
});
|
|
27
|
-
expect(findMatchedLanguage(mockSupportedLanguages, 'GiBBeRish')).toBeUndefined();
|
|
28
|
-
});
|
|
29
|
-
it('should filter supported languages', function () {
|
|
30
|
-
var mockSupportedLanguageStrings = mockSupportedLanguages.map(function (language) {
|
|
31
|
-
return language.name.toLowerCase();
|
|
32
|
-
});
|
|
33
|
-
expect(filterSupportedLanguages([])).toEqual(DEFAULT_LANGUAGES);
|
|
34
|
-
expect(filterSupportedLanguages(mockSupportedLanguageStrings)).toEqual([{
|
|
35
|
-
name: 'Python',
|
|
36
|
-
alias: ['python', 'py'],
|
|
37
|
-
value: 'python'
|
|
38
|
-
}, {
|
|
39
|
-
name: 'JavaScript',
|
|
40
|
-
alias: ['javascript', 'js'],
|
|
41
|
-
value: 'javascript'
|
|
42
|
-
}, {
|
|
43
|
-
name: 'JSON',
|
|
44
|
-
alias: ['json'],
|
|
45
|
-
value: 'json'
|
|
46
|
-
} // '(None)' is not an actual language and should not be 'supported'
|
|
47
|
-
]);
|
|
48
|
-
});
|
|
49
|
-
it('should get language identifier', function () {
|
|
50
|
-
expect(getLanguageIdentifier({
|
|
51
|
-
name: 'MyLanguage',
|
|
52
|
-
alias: ['myalias'],
|
|
53
|
-
value: 'myalias'
|
|
54
|
-
})).toEqual('myalias');
|
|
55
|
-
});
|
|
56
|
-
it('should create language list sorted as case insensitive', function () {
|
|
57
|
-
expect(createLanguageList(mockSupportedLanguages)).toEqual([{
|
|
58
|
-
name: 'JavaScript',
|
|
59
|
-
alias: ['javascript', 'js'],
|
|
60
|
-
value: 'javascript'
|
|
61
|
-
}, {
|
|
62
|
-
name: 'JSON',
|
|
63
|
-
alias: ['json'],
|
|
64
|
-
value: 'json'
|
|
65
|
-
}, {
|
|
66
|
-
name: 'Python',
|
|
67
|
-
alias: ['python', 'py'],
|
|
68
|
-
value: 'python'
|
|
69
|
-
}]);
|
|
70
|
-
});
|
|
71
|
-
});
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
3
|
-
|
|
4
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
5
|
-
|
|
6
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
7
|
-
|
|
8
|
-
import React from 'react';
|
|
9
|
-
import { render, act } from '@testing-library/react';
|
|
10
|
-
import { IntlProvider } from 'react-intl';
|
|
11
|
-
import { SaveIndicator } from './SaveIndicator';
|
|
12
|
-
jest.useFakeTimers();
|
|
13
|
-
|
|
14
|
-
function setup() {
|
|
15
|
-
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
16
|
-
|
|
17
|
-
var onSaveStarted = function onSaveStarted() {};
|
|
18
|
-
|
|
19
|
-
var result = render( /*#__PURE__*/React.createElement(IntlProvider, {
|
|
20
|
-
locale: "en"
|
|
21
|
-
}, /*#__PURE__*/React.createElement(SaveIndicator, _extends({
|
|
22
|
-
duration: 2000
|
|
23
|
-
}, props), function (_ref) {
|
|
24
|
-
var _onSaveStarted = _ref.onSaveStarted;
|
|
25
|
-
onSaveStarted = _onSaveStarted;
|
|
26
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
27
|
-
"data-testid": "my-component"
|
|
28
|
-
});
|
|
29
|
-
})));
|
|
30
|
-
return _objectSpread(_objectSpread({}, result), {}, {
|
|
31
|
-
onSaveStarted: onSaveStarted
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
describe('Extension Context Panel - Save Indicator', function () {
|
|
36
|
-
it('should call the render function ', function () {
|
|
37
|
-
var renderFunction = jest.fn().mockImplementation(function () {
|
|
38
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
39
|
-
"data-testid": "my-component"
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
var _render = render( /*#__PURE__*/React.createElement(IntlProvider, {
|
|
44
|
-
locale: "en"
|
|
45
|
-
}, /*#__PURE__*/React.createElement(SaveIndicator, {
|
|
46
|
-
duration: 1000
|
|
47
|
-
}, renderFunction))),
|
|
48
|
-
queryByTestId = _render.queryByTestId;
|
|
49
|
-
|
|
50
|
-
expect(queryByTestId('my-component')).not.toBeNull();
|
|
51
|
-
});
|
|
52
|
-
it('should show the save indicator when is saving ', function () {
|
|
53
|
-
var _setup = setup(),
|
|
54
|
-
onSaveStarted = _setup.onSaveStarted,
|
|
55
|
-
queryByTestId = _setup.queryByTestId;
|
|
56
|
-
|
|
57
|
-
act(function () {
|
|
58
|
-
onSaveStarted();
|
|
59
|
-
});
|
|
60
|
-
expect(queryByTestId('save-indicator-content')).not.toBeNull();
|
|
61
|
-
});
|
|
62
|
-
it('should hide once the duration is over ', function () {
|
|
63
|
-
jest.clearAllTimers();
|
|
64
|
-
var duration = 2000;
|
|
65
|
-
|
|
66
|
-
var _setup2 = setup({
|
|
67
|
-
duration: duration
|
|
68
|
-
}),
|
|
69
|
-
onSaveStarted = _setup2.onSaveStarted,
|
|
70
|
-
queryByTestId = _setup2.queryByTestId;
|
|
71
|
-
|
|
72
|
-
act(function () {
|
|
73
|
-
onSaveStarted();
|
|
74
|
-
});
|
|
75
|
-
act(function () {
|
|
76
|
-
jest.advanceTimersByTime(duration);
|
|
77
|
-
});
|
|
78
|
-
expect(queryByTestId('save-indicator-content')).toBeNull();
|
|
79
|
-
});
|
|
80
|
-
it('should not show the save indicator after saving when visible is false ', function () {
|
|
81
|
-
var _setup3 = setup({
|
|
82
|
-
visible: false
|
|
83
|
-
}),
|
|
84
|
-
onSaveStarted = _setup3.onSaveStarted,
|
|
85
|
-
queryByTestId = _setup3.queryByTestId;
|
|
86
|
-
|
|
87
|
-
act(function () {
|
|
88
|
-
onSaveStarted();
|
|
89
|
-
});
|
|
90
|
-
expect(queryByTestId('save-indicator-content')).toBeNull();
|
|
91
|
-
});
|
|
92
|
-
});
|