@patternfly/chatbot 6.9.0-prerelease.4 → 6.9.0-prerelease.5
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.
|
@@ -23,7 +23,7 @@ const ChatbotPopover_1 = __importDefault(require("../ChatbotPopover/ChatbotPopov
|
|
|
23
23
|
const ChatbotFootnote = (_a) => {
|
|
24
24
|
var _b, _c, _d, _e, _f;
|
|
25
25
|
var { label, popover, className } = _a, props = __rest(_a, ["label", "popover", "className"]);
|
|
26
|
-
if (
|
|
26
|
+
if (popover && !popover.cta && !popover.showClose) {
|
|
27
27
|
// eslint-disable-next-line no-console
|
|
28
28
|
console.error('ChatbotFootnote: You must provide either the popover.cta or popover.showClose props in order to render a button that can close the popover.');
|
|
29
29
|
}
|
|
@@ -17,7 +17,7 @@ import ChatbotPopover from '../ChatbotPopover/ChatbotPopover';
|
|
|
17
17
|
export const ChatbotFootnote = (_a) => {
|
|
18
18
|
var _b, _c, _d, _e, _f;
|
|
19
19
|
var { label, popover, className } = _a, props = __rest(_a, ["label", "popover", "className"]);
|
|
20
|
-
if (
|
|
20
|
+
if (popover && !popover.cta && !popover.showClose) {
|
|
21
21
|
// eslint-disable-next-line no-console
|
|
22
22
|
console.error('ChatbotFootnote: You must provide either the popover.cta or popover.showClose props in order to render a button that can close the popover.');
|
|
23
23
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/chatbot",
|
|
3
|
-
"version": "6.9.0-prerelease.
|
|
3
|
+
"version": "6.9.0-prerelease.5",
|
|
4
4
|
"description": "This library provides React components based on PatternFly 6 that can be used to build chatbots.",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { act, fireEvent, render, screen, waitFor } from '@testing-library/react';
|
|
2
2
|
import ChatbotFootnote from './ChatbotFootnote';
|
|
3
3
|
|
|
4
|
+
const POPOVER_CLOSE_ERROR =
|
|
5
|
+
'ChatbotFootnote: You must provide either the popover.cta or popover.showClose props in order to render a button that can close the popover.';
|
|
6
|
+
|
|
4
7
|
describe('ChatbotFooternote', () => {
|
|
5
8
|
const onClick = jest.fn();
|
|
6
9
|
const popoverProps = {
|
|
@@ -20,11 +23,58 @@ describe('ChatbotFooternote', () => {
|
|
|
20
23
|
}
|
|
21
24
|
};
|
|
22
25
|
|
|
26
|
+
let consoleErrorSpy: jest.SpyInstance;
|
|
27
|
+
|
|
28
|
+
beforeEach(() => {
|
|
29
|
+
consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation(jest.fn());
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
afterEach(() => {
|
|
33
|
+
consoleErrorSpy.mockRestore();
|
|
34
|
+
});
|
|
35
|
+
|
|
23
36
|
it('should render ChatbotFooternote', () => {
|
|
24
37
|
render(<ChatbotFootnote label="Chatbot footer" />);
|
|
25
38
|
expect(screen.getByText('Chatbot footer')).toBeTruthy();
|
|
26
39
|
});
|
|
27
40
|
|
|
41
|
+
it('should not log a console error when no popover is provided', () => {
|
|
42
|
+
render(<ChatbotFootnote label="Chatbot footer" />);
|
|
43
|
+
expect(consoleErrorSpy).not.toHaveBeenCalledWith(POPOVER_CLOSE_ERROR);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('should not log a console error when popover has a cta', () => {
|
|
47
|
+
render(<ChatbotFootnote label="Chatbot footer" popover={popoverProps} />);
|
|
48
|
+
expect(consoleErrorSpy).not.toHaveBeenCalledWith(POPOVER_CLOSE_ERROR);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('should not log a console error when popover has showClose', () => {
|
|
52
|
+
render(
|
|
53
|
+
<ChatbotFootnote
|
|
54
|
+
label="Chatbot footer"
|
|
55
|
+
popover={{
|
|
56
|
+
title: 'Verify accuracy',
|
|
57
|
+
description: 'description',
|
|
58
|
+
showClose: true
|
|
59
|
+
}}
|
|
60
|
+
/>
|
|
61
|
+
);
|
|
62
|
+
expect(consoleErrorSpy).not.toHaveBeenCalledWith(POPOVER_CLOSE_ERROR);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('should log a console error when popover is provided without cta or showClose', () => {
|
|
66
|
+
render(
|
|
67
|
+
<ChatbotFootnote
|
|
68
|
+
label="Chatbot footer"
|
|
69
|
+
popover={{
|
|
70
|
+
title: 'Verify accuracy',
|
|
71
|
+
description: 'description'
|
|
72
|
+
}}
|
|
73
|
+
/>
|
|
74
|
+
);
|
|
75
|
+
expect(consoleErrorSpy).toHaveBeenCalledWith(POPOVER_CLOSE_ERROR);
|
|
76
|
+
});
|
|
77
|
+
|
|
28
78
|
it('should render ChatbotFooternote with popover', async () => {
|
|
29
79
|
render(<ChatbotFootnote label="Chatbot footer" popover={popoverProps} />);
|
|
30
80
|
|
|
@@ -63,7 +63,7 @@ export const ChatbotFootnote: FunctionComponent<ChatbotFootnoteProps> = ({
|
|
|
63
63
|
className,
|
|
64
64
|
...props
|
|
65
65
|
}: ChatbotFootnoteProps) => {
|
|
66
|
-
if (!popover
|
|
66
|
+
if (popover && !popover.cta && !popover.showClose) {
|
|
67
67
|
// eslint-disable-next-line no-console
|
|
68
68
|
console.error(
|
|
69
69
|
'ChatbotFootnote: You must provide either the popover.cta or popover.showClose props in order to render a button that can close the popover.'
|