@contentful/field-editor-shared 4.6.1-canary.2 → 4.6.1-canary.7
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/dist/cjs/hooks/useLocalePublishStatus.js +1 -1
- package/dist/cjs/hooks/useLocalePublishStatus.spec.js +0 -12
- package/dist/cjs/utils/entityHelpers.test.js +0 -6
- package/dist/esm/hooks/useLocalePublishStatus.js +1 -1
- package/dist/esm/hooks/useLocalePublishStatus.spec.js +0 -12
- package/dist/esm/utils/entityHelpers.test.js +0 -6
- package/package.json +3 -3
|
@@ -30,7 +30,7 @@ function getLocalePublishStatusMap(entity, locales) {
|
|
|
30
30
|
}
|
|
31
31
|
function useLocalePublishStatus(entity, locales) {
|
|
32
32
|
return (0, _react.useMemo)(()=>{
|
|
33
|
-
if (entity
|
|
33
|
+
if (entity && locales) {
|
|
34
34
|
return getLocalePublishStatusMap(entity, locales ? (0, _sanitizeLocales.sanitizeLocales)(locales) : []);
|
|
35
35
|
}
|
|
36
36
|
return undefined;
|
|
@@ -303,17 +303,5 @@ const _useLocalePublishStatus = require("./useLocalePublishStatus");
|
|
|
303
303
|
const { result } = (0, _reacthooks.renderHook)(()=>(0, _useLocalePublishStatus.useLocalePublishStatus)(undefined, localesAPI));
|
|
304
304
|
(0, _vitest.expect)(result.current).toBeUndefined();
|
|
305
305
|
});
|
|
306
|
-
_vitest.it.each([
|
|
307
|
-
{},
|
|
308
|
-
{
|
|
309
|
-
sys: undefined
|
|
310
|
-
},
|
|
311
|
-
{
|
|
312
|
-
sys: null
|
|
313
|
-
}
|
|
314
|
-
])('returns undefined when entity metadata is missing (%j)', (entity)=>{
|
|
315
|
-
const { result } = (0, _reacthooks.renderHook)(()=>(0, _useLocalePublishStatus.useLocalePublishStatus)(entity, localesAPI));
|
|
316
|
-
(0, _vitest.expect)(result.current).toBeUndefined();
|
|
317
|
-
});
|
|
318
306
|
});
|
|
319
307
|
});
|
|
@@ -5,12 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
const _vitest = require("vitest");
|
|
6
6
|
const _entityHelpers = require("./entityHelpers");
|
|
7
7
|
(0, _vitest.describe)('getEntityStatus', ()=>{
|
|
8
|
-
_vitest.test.each([
|
|
9
|
-
undefined,
|
|
10
|
-
null
|
|
11
|
-
])('rejects missing metadata (%s)', (sys)=>{
|
|
12
|
-
(0, _vitest.expect)(()=>(0, _entityHelpers.getEntityStatus)(sys)).toThrow(new TypeError('Invalid entity metadata object'));
|
|
13
|
-
});
|
|
14
8
|
function createEntity(props) {
|
|
15
9
|
return props;
|
|
16
10
|
}
|
|
@@ -20,7 +20,7 @@ function getLocalePublishStatusMap(entity, locales) {
|
|
|
20
20
|
}
|
|
21
21
|
export function useLocalePublishStatus(entity, locales) {
|
|
22
22
|
return useMemo(()=>{
|
|
23
|
-
if (entity
|
|
23
|
+
if (entity && locales) {
|
|
24
24
|
return getLocalePublishStatusMap(entity, locales ? sanitizeLocales(locales) : []);
|
|
25
25
|
}
|
|
26
26
|
return undefined;
|
|
@@ -299,17 +299,5 @@ describe('useLocalePublishStatus', ()=>{
|
|
|
299
299
|
const { result } = renderHook(()=>useLocalePublishStatus(undefined, localesAPI));
|
|
300
300
|
expect(result.current).toBeUndefined();
|
|
301
301
|
});
|
|
302
|
-
it.each([
|
|
303
|
-
{},
|
|
304
|
-
{
|
|
305
|
-
sys: undefined
|
|
306
|
-
},
|
|
307
|
-
{
|
|
308
|
-
sys: null
|
|
309
|
-
}
|
|
310
|
-
])('returns undefined when entity metadata is missing (%j)', (entity)=>{
|
|
311
|
-
const { result } = renderHook(()=>useLocalePublishStatus(entity, localesAPI));
|
|
312
|
-
expect(result.current).toBeUndefined();
|
|
313
|
-
});
|
|
314
302
|
});
|
|
315
303
|
});
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import { describe, expect, test } from 'vitest';
|
|
2
2
|
import { getEntityStatus, getResolvedImageUrl } from './entityHelpers';
|
|
3
3
|
describe('getEntityStatus', ()=>{
|
|
4
|
-
test.each([
|
|
5
|
-
undefined,
|
|
6
|
-
null
|
|
7
|
-
])('rejects missing metadata (%s)', (sys)=>{
|
|
8
|
-
expect(()=>getEntityStatus(sys)).toThrow(new TypeError('Invalid entity metadata object'));
|
|
9
|
-
});
|
|
10
4
|
function createEntity(props) {
|
|
11
5
|
return props;
|
|
12
6
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/field-editor-shared",
|
|
3
|
-
"version": "4.6.1-canary.
|
|
3
|
+
"version": "4.6.1-canary.7+98e4f98c",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@contentful/app-sdk": "^4.42.0",
|
|
48
|
-
"@contentful/field-editor-test-utils": "^3.2.
|
|
48
|
+
"@contentful/field-editor-test-utils": "^3.2.1-canary.7+98e4f98c",
|
|
49
49
|
"@lingui/core": "5.3.0",
|
|
50
50
|
"@tanstack/react-query": "^4.3.9",
|
|
51
51
|
"@testing-library/react": "16.3.0"
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
"prettier --write"
|
|
82
82
|
]
|
|
83
83
|
},
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "98e4f98c23571f17e08e02c80c7d7e249412fc49"
|
|
85
85
|
}
|