@evfrenkel/decap-cms-core 3.13.0-image-conversions.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/README.md +9 -0
- package/dist/20.decap-cms-core.js +2 -0
- package/dist/20.decap-cms-core.js.map +1 -0
- package/dist/3802306e7b58a11862fb.wasm +0 -0
- package/dist/@evfrenkel/20.decap-cms-core.js +2 -0
- package/dist/@evfrenkel/20.decap-cms-core.js.map +1 -0
- package/dist/@evfrenkel/decap-cms-core.js +44 -0
- package/dist/@evfrenkel/decap-cms-core.js.LICENSE.txt +126 -0
- package/dist/@evfrenkel/decap-cms-core.js.map +1 -0
- package/dist/decap-cms-core.js +47 -0
- package/dist/decap-cms-core.js.LICENSE.txt +126 -0
- package/dist/decap-cms-core.js.map +1 -0
- package/dist/esm/actions/auth.js +97 -0
- package/dist/esm/actions/collections.js +15 -0
- package/dist/esm/actions/config.js +503 -0
- package/dist/esm/actions/deploys.js +80 -0
- package/dist/esm/actions/editorialWorkflow.js +480 -0
- package/dist/esm/actions/entries.js +876 -0
- package/dist/esm/actions/media.js +147 -0
- package/dist/esm/actions/mediaLibrary.js +599 -0
- package/dist/esm/actions/notifications.js +21 -0
- package/dist/esm/actions/search.js +149 -0
- package/dist/esm/actions/status.js +74 -0
- package/dist/esm/actions/waitUntil.js +32 -0
- package/dist/esm/backend.js +1090 -0
- package/dist/esm/bootstrap.js +101 -0
- package/dist/esm/components/App/App.js +296 -0
- package/dist/esm/components/App/Header.js +172 -0
- package/dist/esm/components/App/NotFoundPage.js +19 -0
- package/dist/esm/components/Collection/Collection.js +198 -0
- package/dist/esm/components/Collection/CollectionControls.js +47 -0
- package/dist/esm/components/Collection/CollectionSearch.js +222 -0
- package/dist/esm/components/Collection/CollectionTop.js +68 -0
- package/dist/esm/components/Collection/ControlButton.js +17 -0
- package/dist/esm/components/Collection/Entries/Entries.js +73 -0
- package/dist/esm/components/Collection/Entries/EntriesCollection.js +241 -0
- package/dist/esm/components/Collection/Entries/EntriesSearch.js +113 -0
- package/dist/esm/components/Collection/Entries/EntryCard.js +192 -0
- package/dist/esm/components/Collection/Entries/EntryListing.js +143 -0
- package/dist/esm/components/Collection/FilterControl.js +33 -0
- package/dist/esm/components/Collection/GroupControl.js +33 -0
- package/dist/esm/components/Collection/NestedCollection.js +308 -0
- package/dist/esm/components/Collection/Sidebar.js +91 -0
- package/dist/esm/components/Collection/SortControl.js +59 -0
- package/dist/esm/components/Collection/ViewStyleControl.js +41 -0
- package/dist/esm/components/Editor/Editor.js +466 -0
- package/dist/esm/components/Editor/EditorControlPane/EditorControl.js +398 -0
- package/dist/esm/components/Editor/EditorControlPane/EditorControlPane.js +254 -0
- package/dist/esm/components/Editor/EditorControlPane/Widget.js +374 -0
- package/dist/esm/components/Editor/EditorInterface.js +386 -0
- package/dist/esm/components/Editor/EditorPreviewPane/EditorPreview.js +47 -0
- package/dist/esm/components/Editor/EditorPreviewPane/EditorPreviewContent.js +67 -0
- package/dist/esm/components/Editor/EditorPreviewPane/EditorPreviewPane.js +306 -0
- package/dist/esm/components/Editor/EditorPreviewPane/PreviewHOC.js +27 -0
- package/dist/esm/components/Editor/EditorToolbar.js +554 -0
- package/dist/esm/components/Editor/withWorkflow.js +56 -0
- package/dist/esm/components/EditorWidgets/Unknown/UnknownControl.js +18 -0
- package/dist/esm/components/EditorWidgets/Unknown/UnknownPreview.js +20 -0
- package/dist/esm/components/EditorWidgets/index.js +4 -0
- package/dist/esm/components/MediaLibrary/EmptyMessage.js +22 -0
- package/dist/esm/components/MediaLibrary/MediaLibrary.js +446 -0
- package/dist/esm/components/MediaLibrary/MediaLibraryButtons.js +92 -0
- package/dist/esm/components/MediaLibrary/MediaLibraryCard.js +99 -0
- package/dist/esm/components/MediaLibrary/MediaLibraryCardGrid.js +198 -0
- package/dist/esm/components/MediaLibrary/MediaLibraryHeader.js +34 -0
- package/dist/esm/components/MediaLibrary/MediaLibraryModal.js +156 -0
- package/dist/esm/components/MediaLibrary/MediaLibrarySearch.js +51 -0
- package/dist/esm/components/MediaLibrary/MediaLibraryTop.js +124 -0
- package/dist/esm/components/UI/DragDrop.js +67 -0
- package/dist/esm/components/UI/ErrorBoundary.js +170 -0
- package/dist/esm/components/UI/FileUploadButton.js +27 -0
- package/dist/esm/components/UI/Modal.js +104 -0
- package/dist/esm/components/UI/Notifications.js +62 -0
- package/dist/esm/components/UI/SettingsDropdown.js +107 -0
- package/dist/esm/components/UI/index.js +6 -0
- package/dist/esm/components/Workflow/Workflow.js +133 -0
- package/dist/esm/components/Workflow/WorkflowCard.js +128 -0
- package/dist/esm/components/Workflow/WorkflowList.js +204 -0
- package/dist/esm/constants/collectionTypes.js +2 -0
- package/dist/esm/constants/collectionViews.js +2 -0
- package/dist/esm/constants/commitProps.js +2 -0
- package/dist/esm/constants/configSchema.js +695 -0
- package/dist/esm/constants/fieldInference.js +57 -0
- package/dist/esm/constants/publishModes.js +18 -0
- package/dist/esm/constants/validationErrorTypes.js +6 -0
- package/dist/esm/formats/formats.js +83 -0
- package/dist/esm/formats/frontmatter.js +146 -0
- package/dist/esm/formats/helpers.js +12 -0
- package/dist/esm/formats/json.js +8 -0
- package/dist/esm/formats/toml.js +32 -0
- package/dist/esm/formats/yaml.js +60 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/integrations/index.js +28 -0
- package/dist/esm/integrations/providers/algolia/implementation.js +174 -0
- package/dist/esm/integrations/providers/assetStore/implementation.js +165 -0
- package/dist/esm/lib/consoleError.js +3 -0
- package/dist/esm/lib/formatters.js +201 -0
- package/dist/esm/lib/i18n.js +372 -0
- package/dist/esm/lib/imageTransformations.js +143 -0
- package/dist/esm/lib/phrases.js +6 -0
- package/dist/esm/lib/polyfill.js +8 -0
- package/dist/esm/lib/registry.js +332 -0
- package/dist/esm/lib/serializeEntryValues.js +67 -0
- package/dist/esm/lib/stega.js +142 -0
- package/dist/esm/lib/textHelper.js +9 -0
- package/dist/esm/lib/urlHelper.js +129 -0
- package/dist/esm/mediaLibrary.js +37 -0
- package/dist/esm/reducers/auth.js +27 -0
- package/dist/esm/reducers/collections.js +428 -0
- package/dist/esm/reducers/combinedReducer.js +8 -0
- package/dist/esm/reducers/config.js +29 -0
- package/dist/esm/reducers/cursors.js +31 -0
- package/dist/esm/reducers/deploys.js +50 -0
- package/dist/esm/reducers/editorialWorkflow.js +83 -0
- package/dist/esm/reducers/entries.js +568 -0
- package/dist/esm/reducers/entryDraft.js +211 -0
- package/dist/esm/reducers/globalUI.js +25 -0
- package/dist/esm/reducers/index.js +66 -0
- package/dist/esm/reducers/integrations.js +53 -0
- package/dist/esm/reducers/mediaLibrary.js +252 -0
- package/dist/esm/reducers/medias.js +68 -0
- package/dist/esm/reducers/notifications.js +23 -0
- package/dist/esm/reducers/search.js +92 -0
- package/dist/esm/reducers/status.js +30 -0
- package/dist/esm/redux/index.js +7 -0
- package/dist/esm/redux/middleware/waitUntilAction.js +48 -0
- package/dist/esm/routing/history.js +12 -0
- package/dist/esm/types/diacritics.d.js +0 -0
- package/dist/esm/types/global.d.js +1 -0
- package/dist/esm/types/immutable.js +7 -0
- package/dist/esm/types/redux.js +14 -0
- package/dist/esm/types/tomlify-j0.4.d.js +0 -0
- package/dist/esm/valueObjects/AssetProxy.js +44 -0
- package/dist/esm/valueObjects/EditorComponent.js +34 -0
- package/dist/esm/valueObjects/Entry.js +20 -0
- package/index.d.ts +662 -0
- package/package.json +100 -0
- package/src/__tests__/backend.spec.js +1223 -0
- package/src/actions/__tests__/config.spec.js +1023 -0
- package/src/actions/__tests__/editorialWorkflow.spec.js +216 -0
- package/src/actions/__tests__/entries.spec.js +610 -0
- package/src/actions/__tests__/media.spec.ts +171 -0
- package/src/actions/__tests__/mediaLibrary.spec.js +462 -0
- package/src/actions/__tests__/search.spec.js +209 -0
- package/src/actions/auth.ts +127 -0
- package/src/actions/collections.ts +18 -0
- package/src/actions/config.ts +574 -0
- package/src/actions/deploys.ts +105 -0
- package/src/actions/editorialWorkflow.ts +567 -0
- package/src/actions/entries.ts +1070 -0
- package/src/actions/media.ts +139 -0
- package/src/actions/mediaLibrary.ts +639 -0
- package/src/actions/notifications.ts +36 -0
- package/src/actions/search.ts +221 -0
- package/src/actions/status.ts +99 -0
- package/src/actions/waitUntil.ts +49 -0
- package/src/backend.ts +1411 -0
- package/src/bootstrap.js +104 -0
- package/src/components/App/App.js +295 -0
- package/src/components/App/Header.js +291 -0
- package/src/components/App/NotFoundPage.js +23 -0
- package/src/components/Collection/Collection.js +210 -0
- package/src/components/Collection/CollectionControls.js +58 -0
- package/src/components/Collection/CollectionSearch.js +243 -0
- package/src/components/Collection/CollectionTop.js +81 -0
- package/src/components/Collection/ControlButton.js +27 -0
- package/src/components/Collection/Entries/Entries.js +82 -0
- package/src/components/Collection/Entries/EntriesCollection.js +277 -0
- package/src/components/Collection/Entries/EntriesSearch.js +102 -0
- package/src/components/Collection/Entries/EntryCard.js +256 -0
- package/src/components/Collection/Entries/EntryListing.js +151 -0
- package/src/components/Collection/Entries/__tests__/EntriesCollection.spec.js +163 -0
- package/src/components/Collection/Entries/__tests__/__snapshots__/EntriesCollection.spec.js.snap +46 -0
- package/src/components/Collection/FilterControl.js +39 -0
- package/src/components/Collection/GroupControl.js +39 -0
- package/src/components/Collection/NestedCollection.js +330 -0
- package/src/components/Collection/Sidebar.js +136 -0
- package/src/components/Collection/SortControl.js +68 -0
- package/src/components/Collection/ViewStyleControl.js +52 -0
- package/src/components/Collection/__tests__/Collection.spec.js +75 -0
- package/src/components/Collection/__tests__/NestedCollection.spec.js +445 -0
- package/src/components/Collection/__tests__/Sidebar.spec.js +87 -0
- package/src/components/Collection/__tests__/__snapshots__/Collection.spec.js.snap +144 -0
- package/src/components/Collection/__tests__/__snapshots__/NestedCollection.spec.js.snap +550 -0
- package/src/components/Collection/__tests__/__snapshots__/Sidebar.spec.js.snap +312 -0
- package/src/components/Editor/Editor.js +497 -0
- package/src/components/Editor/EditorControlPane/EditorControl.js +453 -0
- package/src/components/Editor/EditorControlPane/EditorControlPane.js +269 -0
- package/src/components/Editor/EditorControlPane/Widget.js +384 -0
- package/src/components/Editor/EditorInterface.js +444 -0
- package/src/components/Editor/EditorPreviewPane/EditorPreview.js +40 -0
- package/src/components/Editor/EditorPreviewPane/EditorPreviewContent.js +75 -0
- package/src/components/Editor/EditorPreviewPane/EditorPreviewPane.js +337 -0
- package/src/components/Editor/EditorPreviewPane/PreviewHOC.js +33 -0
- package/src/components/Editor/EditorToolbar.js +728 -0
- package/src/components/Editor/__tests__/Editor.spec.js +221 -0
- package/src/components/Editor/__tests__/EditorToolbar.spec.js +166 -0
- package/src/components/Editor/__tests__/__snapshots__/Editor.spec.js.snap +45 -0
- package/src/components/Editor/__tests__/__snapshots__/EditorToolbar.spec.js.snap +4265 -0
- package/src/components/Editor/withWorkflow.js +61 -0
- package/src/components/EditorWidgets/Unknown/UnknownControl.js +17 -0
- package/src/components/EditorWidgets/Unknown/UnknownPreview.js +19 -0
- package/src/components/EditorWidgets/index.js +5 -0
- package/src/components/MediaLibrary/EmptyMessage.js +28 -0
- package/src/components/MediaLibrary/MediaLibrary.js +411 -0
- package/src/components/MediaLibrary/MediaLibraryButtons.js +135 -0
- package/src/components/MediaLibrary/MediaLibraryCard.js +128 -0
- package/src/components/MediaLibrary/MediaLibraryCardGrid.js +199 -0
- package/src/components/MediaLibrary/MediaLibraryHeader.js +48 -0
- package/src/components/MediaLibrary/MediaLibraryModal.js +200 -0
- package/src/components/MediaLibrary/MediaLibrarySearch.js +61 -0
- package/src/components/MediaLibrary/MediaLibraryTop.js +144 -0
- package/src/components/MediaLibrary/__tests__/MediaLibraryButtons.spec.js +45 -0
- package/src/components/MediaLibrary/__tests__/MediaLibraryCard.spec.js +49 -0
- package/src/components/MediaLibrary/__tests__/__snapshots__/MediaLibraryCard.spec.js.snap +264 -0
- package/src/components/UI/DragDrop.js +66 -0
- package/src/components/UI/ErrorBoundary.js +213 -0
- package/src/components/UI/FileUploadButton.js +24 -0
- package/src/components/UI/Modal.js +112 -0
- package/src/components/UI/Notifications.tsx +83 -0
- package/src/components/UI/SettingsDropdown.js +130 -0
- package/src/components/UI/__tests__/ErrorBoundary.spec.js +57 -0
- package/src/components/UI/index.js +6 -0
- package/src/components/Workflow/Workflow.js +169 -0
- package/src/components/Workflow/WorkflowCard.js +177 -0
- package/src/components/Workflow/WorkflowList.js +272 -0
- package/src/constants/__tests__/configSchema.spec.js +644 -0
- package/src/constants/collectionTypes.ts +2 -0
- package/src/constants/collectionViews.js +2 -0
- package/src/constants/commitProps.ts +2 -0
- package/src/constants/configSchema.js +489 -0
- package/src/constants/fieldInference.tsx +78 -0
- package/src/constants/publishModes.ts +22 -0
- package/src/constants/validationErrorTypes.js +6 -0
- package/src/formats/__tests__/formats.spec.js +87 -0
- package/src/formats/__tests__/frontmatter.spec.js +450 -0
- package/src/formats/__tests__/toml.spec.js +9 -0
- package/src/formats/__tests__/yaml.spec.js +189 -0
- package/src/formats/formats.ts +97 -0
- package/src/formats/frontmatter.ts +150 -0
- package/src/formats/helpers.ts +14 -0
- package/src/formats/json.ts +9 -0
- package/src/formats/toml.ts +33 -0
- package/src/formats/yaml.ts +73 -0
- package/src/index.js +8 -0
- package/src/integrations/index.js +35 -0
- package/src/integrations/providers/algolia/implementation.js +176 -0
- package/src/integrations/providers/assetStore/implementation.js +148 -0
- package/src/lib/__tests__/formatters.spec.js +844 -0
- package/src/lib/__tests__/i18n.spec.js +792 -0
- package/src/lib/__tests__/imageTransformations.spec.ts +97 -0
- package/src/lib/__tests__/phrases.spec.js +119 -0
- package/src/lib/__tests__/registry.spec.js +261 -0
- package/src/lib/__tests__/serializeEntryValues.spec.js +22 -0
- package/src/lib/__tests__/urlHelper.spec.js +145 -0
- package/src/lib/consoleError.js +7 -0
- package/src/lib/formatters.ts +297 -0
- package/src/lib/i18n.ts +462 -0
- package/src/lib/imageTransformations.ts +212 -0
- package/src/lib/phrases.js +8 -0
- package/src/lib/polyfill.js +9 -0
- package/src/lib/registry.js +315 -0
- package/src/lib/serializeEntryValues.js +75 -0
- package/src/lib/stega.ts +145 -0
- package/src/lib/textHelper.js +11 -0
- package/src/lib/urlHelper.ts +152 -0
- package/src/mediaLibrary.ts +51 -0
- package/src/reducers/__tests__/auth.spec.ts +38 -0
- package/src/reducers/__tests__/collections.spec.js +610 -0
- package/src/reducers/__tests__/config.spec.js +38 -0
- package/src/reducers/__tests__/deploys.spec.ts +111 -0
- package/src/reducers/__tests__/entries.spec.js +694 -0
- package/src/reducers/__tests__/entryDraft.spec.js +315 -0
- package/src/reducers/__tests__/globalUI.js +43 -0
- package/src/reducers/__tests__/integrations.spec.ts +76 -0
- package/src/reducers/__tests__/mediaLibrary.spec.js +154 -0
- package/src/reducers/__tests__/medias.spec.ts +49 -0
- package/src/reducers/auth.ts +46 -0
- package/src/reducers/collections.ts +535 -0
- package/src/reducers/combinedReducer.ts +11 -0
- package/src/reducers/config.ts +38 -0
- package/src/reducers/cursors.js +36 -0
- package/src/reducers/deploys.ts +54 -0
- package/src/reducers/editorialWorkflow.ts +163 -0
- package/src/reducers/entries.ts +819 -0
- package/src/reducers/entryDraft.js +259 -0
- package/src/reducers/globalUI.ts +45 -0
- package/src/reducers/index.ts +82 -0
- package/src/reducers/integrations.ts +59 -0
- package/src/reducers/mediaLibrary.ts +296 -0
- package/src/reducers/medias.ts +66 -0
- package/src/reducers/notifications.ts +52 -0
- package/src/reducers/search.ts +111 -0
- package/src/reducers/status.ts +40 -0
- package/src/redux/index.ts +18 -0
- package/src/redux/middleware/waitUntilAction.ts +64 -0
- package/src/routing/__tests__/history.spec.ts +49 -0
- package/src/routing/history.ts +17 -0
- package/src/types/diacritics.d.ts +1 -0
- package/src/types/global.d.ts +8 -0
- package/src/types/immutable.ts +49 -0
- package/src/types/redux.ts +875 -0
- package/src/types/tomlify-j0.4.d.ts +13 -0
- package/src/valueObjects/AssetProxy.ts +48 -0
- package/src/valueObjects/EditorComponent.js +38 -0
- package/src/valueObjects/Entry.ts +63 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { configLoaded, configLoading, configFailed } from '../../actions/config';
|
|
2
|
+
import config, { selectLocale } from '../config';
|
|
3
|
+
|
|
4
|
+
describe('config', () => {
|
|
5
|
+
it('should handle an empty state', () => {
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
7
|
+
// @ts-ignore config reducer doesn't accept empty action
|
|
8
|
+
expect(config(undefined, {})).toEqual({ isFetching: true });
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it('should handle an update', () => {
|
|
12
|
+
expect(
|
|
13
|
+
config({ isFetching: true }, configLoaded({ locale: 'fr', backend: { name: 'proxy' } })),
|
|
14
|
+
).toEqual({
|
|
15
|
+
locale: 'fr',
|
|
16
|
+
backend: { name: 'proxy' },
|
|
17
|
+
isFetching: false,
|
|
18
|
+
error: undefined,
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('should mark the config as loading', () => {
|
|
23
|
+
expect(config({ isFetching: false }, configLoading())).toEqual({ isFetching: true });
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('should handle an error', () => {
|
|
27
|
+
expect(
|
|
28
|
+
config({ isFetching: true }, configFailed(new Error('Config could not be loaded'))),
|
|
29
|
+
).toEqual({
|
|
30
|
+
error: 'Error: Config could not be loaded',
|
|
31
|
+
isFetching: false,
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('should default to "en" locale', () => {
|
|
36
|
+
expect(selectLocale({})).toEqual('en');
|
|
37
|
+
});
|
|
38
|
+
});
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import deploys, { selectDeployPreview } from '../deploys';
|
|
2
|
+
import {
|
|
3
|
+
DEPLOY_PREVIEW_REQUEST,
|
|
4
|
+
DEPLOY_PREVIEW_SUCCESS,
|
|
5
|
+
DEPLOY_PREVIEW_FAILURE,
|
|
6
|
+
} from '../../actions/deploys';
|
|
7
|
+
|
|
8
|
+
describe('deploys reducer', () => {
|
|
9
|
+
it('should return the default state', () => {
|
|
10
|
+
const result = deploys(undefined, { type: 'UNKNOWN' });
|
|
11
|
+
expect(result).toEqual({});
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
describe('DEPLOY_PREVIEW_REQUEST', () => {
|
|
15
|
+
it('should set isFetching to true and status to PENDING', () => {
|
|
16
|
+
const result = deploys(undefined, {
|
|
17
|
+
type: DEPLOY_PREVIEW_REQUEST,
|
|
18
|
+
payload: { collection: 'posts', slug: 'my-post' },
|
|
19
|
+
});
|
|
20
|
+
expect(result['posts.my-post']).toEqual({ isFetching: true, status: 'PENDING' });
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('should clear stale url and replace status with PENDING', () => {
|
|
24
|
+
const staleState = {
|
|
25
|
+
'posts.my-post': {
|
|
26
|
+
isFetching: false,
|
|
27
|
+
url: 'https://production.example.com/posts/my-post',
|
|
28
|
+
status: 'SUCCESS',
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
const result = deploys(staleState, {
|
|
32
|
+
type: DEPLOY_PREVIEW_REQUEST,
|
|
33
|
+
payload: { collection: 'posts', slug: 'my-post' },
|
|
34
|
+
});
|
|
35
|
+
expect(result['posts.my-post']).toEqual({ isFetching: true, status: 'PENDING' });
|
|
36
|
+
expect(result['posts.my-post'].url).toBeUndefined();
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
describe('DEPLOY_PREVIEW_SUCCESS', () => {
|
|
41
|
+
it('should store the deploy preview url and status', () => {
|
|
42
|
+
const initialState = {
|
|
43
|
+
'posts.my-post': { isFetching: true },
|
|
44
|
+
};
|
|
45
|
+
const result = deploys(initialState, {
|
|
46
|
+
type: DEPLOY_PREVIEW_SUCCESS,
|
|
47
|
+
payload: {
|
|
48
|
+
collection: 'posts',
|
|
49
|
+
slug: 'my-post',
|
|
50
|
+
url: 'https://preview.example.com/posts/my-post',
|
|
51
|
+
status: 'SUCCESS',
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
expect(result['posts.my-post']).toEqual({
|
|
55
|
+
isFetching: false,
|
|
56
|
+
url: 'https://preview.example.com/posts/my-post',
|
|
57
|
+
status: 'SUCCESS',
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
describe('DEPLOY_PREVIEW_FAILURE', () => {
|
|
63
|
+
it('should set isFetching to false and status to PENDING', () => {
|
|
64
|
+
const initialState = {
|
|
65
|
+
'posts.my-post': { isFetching: true, status: 'PENDING' },
|
|
66
|
+
};
|
|
67
|
+
const result = deploys(initialState, {
|
|
68
|
+
type: DEPLOY_PREVIEW_FAILURE,
|
|
69
|
+
payload: { collection: 'posts', slug: 'my-post' },
|
|
70
|
+
});
|
|
71
|
+
expect(result['posts.my-post'].isFetching).toBe(false);
|
|
72
|
+
expect(result['posts.my-post'].status).toBe('PENDING');
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('should clear url and replace status with PENDING to prevent stale data', () => {
|
|
76
|
+
const initialState = {
|
|
77
|
+
'posts.my-post': {
|
|
78
|
+
isFetching: true,
|
|
79
|
+
url: 'https://production.example.com/posts/my-post',
|
|
80
|
+
status: 'SUCCESS',
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
const result = deploys(initialState, {
|
|
84
|
+
type: DEPLOY_PREVIEW_FAILURE,
|
|
85
|
+
payload: { collection: 'posts', slug: 'my-post' },
|
|
86
|
+
});
|
|
87
|
+
expect(result['posts.my-post']).toEqual({
|
|
88
|
+
isFetching: false,
|
|
89
|
+
url: undefined,
|
|
90
|
+
status: 'PENDING',
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
describe('selectDeployPreview', () => {
|
|
96
|
+
it('should return the deploy preview for a given collection and slug', () => {
|
|
97
|
+
const state = {
|
|
98
|
+
'posts.my-post': {
|
|
99
|
+
isFetching: false,
|
|
100
|
+
url: 'https://preview.example.com/posts/my-post',
|
|
101
|
+
status: 'SUCCESS',
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
expect(selectDeployPreview(state, 'posts', 'my-post')).toBe(state['posts.my-post']);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it('should return undefined for unknown collection/slug', () => {
|
|
108
|
+
expect(selectDeployPreview({}, 'posts', 'unknown')).toBeUndefined();
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
});
|