@contentful/field-editor-rich-text 6.6.0 → 6.6.1-canary.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.
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
const _reacthooks = require("@testing-library/react-hooks");
|
|
6
|
+
const _vitest = require("vitest");
|
|
7
|
+
const _useEntityInfo = require("./useEntityInfo");
|
|
8
|
+
_vitest.vi.mock('./utils', ()=>({
|
|
9
|
+
getEntityInfo: _vitest.vi.fn()
|
|
10
|
+
}));
|
|
11
|
+
(0, _vitest.afterEach)(()=>_vitest.vi.restoreAllMocks());
|
|
12
|
+
_vitest.describe.each([
|
|
13
|
+
'Entry',
|
|
14
|
+
'Asset'
|
|
15
|
+
])('%s hyperlink information', (linkType)=>{
|
|
16
|
+
_vitest.test.each([
|
|
17
|
+
undefined,
|
|
18
|
+
null,
|
|
19
|
+
{},
|
|
20
|
+
{
|
|
21
|
+
sys: undefined
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
sys: null
|
|
25
|
+
}
|
|
26
|
+
])('shows an inaccessible state when fetched metadata is missing (%j)', async (entity)=>{
|
|
27
|
+
_vitest.vi.spyOn(console, 'log').mockImplementation(()=>undefined);
|
|
28
|
+
const get = _vitest.vi.fn().mockResolvedValue(entity);
|
|
29
|
+
const sdk = {
|
|
30
|
+
cma: {
|
|
31
|
+
entry: {
|
|
32
|
+
get
|
|
33
|
+
},
|
|
34
|
+
asset: {
|
|
35
|
+
get
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
field: {
|
|
39
|
+
locale: 'en-US'
|
|
40
|
+
},
|
|
41
|
+
locales: {
|
|
42
|
+
default: 'en-US'
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
const target = {
|
|
46
|
+
sys: {
|
|
47
|
+
type: 'Link',
|
|
48
|
+
id: 'linked-id',
|
|
49
|
+
linkType
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
const onEntityFetchComplete = _vitest.vi.fn();
|
|
53
|
+
const { result, waitFor } = (0, _reacthooks.renderHook)(()=>(0, _useEntityInfo.useEntityInfo)({
|
|
54
|
+
sdk,
|
|
55
|
+
target,
|
|
56
|
+
onEntityFetchComplete
|
|
57
|
+
}));
|
|
58
|
+
await waitFor(()=>{
|
|
59
|
+
(0, _vitest.expect)(result.current).toBe(`${linkType} missing or inaccessible`);
|
|
60
|
+
});
|
|
61
|
+
(0, _vitest.expect)(result.error).toBeUndefined();
|
|
62
|
+
(0, _vitest.expect)(onEntityFetchComplete).toHaveBeenCalledOnce();
|
|
63
|
+
});
|
|
64
|
+
});
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { renderHook } from '@testing-library/react-hooks';
|
|
2
|
+
import { afterEach, describe, expect, test, vi } from 'vitest';
|
|
3
|
+
import { useEntityInfo } from './useEntityInfo';
|
|
4
|
+
vi.mock('./utils', ()=>({
|
|
5
|
+
getEntityInfo: vi.fn()
|
|
6
|
+
}));
|
|
7
|
+
afterEach(()=>vi.restoreAllMocks());
|
|
8
|
+
describe.each([
|
|
9
|
+
'Entry',
|
|
10
|
+
'Asset'
|
|
11
|
+
])('%s hyperlink information', (linkType)=>{
|
|
12
|
+
test.each([
|
|
13
|
+
undefined,
|
|
14
|
+
null,
|
|
15
|
+
{},
|
|
16
|
+
{
|
|
17
|
+
sys: undefined
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
sys: null
|
|
21
|
+
}
|
|
22
|
+
])('shows an inaccessible state when fetched metadata is missing (%j)', async (entity)=>{
|
|
23
|
+
vi.spyOn(console, 'log').mockImplementation(()=>undefined);
|
|
24
|
+
const get = vi.fn().mockResolvedValue(entity);
|
|
25
|
+
const sdk = {
|
|
26
|
+
cma: {
|
|
27
|
+
entry: {
|
|
28
|
+
get
|
|
29
|
+
},
|
|
30
|
+
asset: {
|
|
31
|
+
get
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
field: {
|
|
35
|
+
locale: 'en-US'
|
|
36
|
+
},
|
|
37
|
+
locales: {
|
|
38
|
+
default: 'en-US'
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
const target = {
|
|
42
|
+
sys: {
|
|
43
|
+
type: 'Link',
|
|
44
|
+
id: 'linked-id',
|
|
45
|
+
linkType
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
const onEntityFetchComplete = vi.fn();
|
|
49
|
+
const { result, waitFor } = renderHook(()=>useEntityInfo({
|
|
50
|
+
sdk,
|
|
51
|
+
target,
|
|
52
|
+
onEntityFetchComplete
|
|
53
|
+
}));
|
|
54
|
+
await waitFor(()=>{
|
|
55
|
+
expect(result.current).toBe(`${linkType} missing or inaccessible`);
|
|
56
|
+
});
|
|
57
|
+
expect(result.error).toBeUndefined();
|
|
58
|
+
expect(onEntityFetchComplete).toHaveBeenCalledOnce();
|
|
59
|
+
});
|
|
60
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/field-editor-rich-text",
|
|
3
|
-
"version": "6.6.0",
|
|
3
|
+
"version": "6.6.1-canary.0+645c9b0b",
|
|
4
4
|
"source": "./src/index.tsx",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"@contentful/f36-icons": "^6.7.1",
|
|
47
47
|
"@contentful/f36-tokens": "^6.1.2",
|
|
48
48
|
"@contentful/f36-utils": "^6.1.0",
|
|
49
|
-
"@contentful/field-editor-reference": "^8.5.
|
|
50
|
-
"@contentful/field-editor-shared": "^4.6.
|
|
49
|
+
"@contentful/field-editor-reference": "^8.5.1-canary.2+645c9b0b",
|
|
50
|
+
"@contentful/field-editor-shared": "^4.6.1-canary.2+645c9b0b",
|
|
51
51
|
"@contentful/rich-text-plain-text-renderer": "^17.0.0",
|
|
52
52
|
"@contentful/rich-text-types": "^17.2.5",
|
|
53
53
|
"@emotion/css": "^11.13.5",
|
|
@@ -96,5 +96,5 @@
|
|
|
96
96
|
"prettier --write"
|
|
97
97
|
]
|
|
98
98
|
},
|
|
99
|
-
"gitHead": "
|
|
99
|
+
"gitHead": "645c9b0ba09820f91776cb981448ff8b9abe4202"
|
|
100
100
|
}
|