@innovaccer/design-system 2.5.0-2 → 2.5.1
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/.all-contributorsrc +170 -0
- package/.github/workflows/jira.yml +1 -2
- package/.github/workflows/main.yml +1 -6
- package/.github/workflows/test.yml +22 -0
- package/CHANGELOG.md +21 -54
- package/CONTRIBUTING.md +23 -0
- package/README.md +124 -75
- package/core/components/atoms/button/Button.tsx +56 -55
- package/core/components/atoms/button/__tests__/Button.test.tsx +3 -12
- package/core/components/atoms/checkbox/Checkbox.tsx +3 -6
- package/core/components/atoms/collapsible/__stories__/index.story.tsx +2 -2
- package/core/components/atoms/dropdown/DropdownList.tsx +1 -1
- package/core/components/atoms/dropdown/__stories__/Options.tsx +15 -0
- package/core/components/atoms/dropdown/__tests__/Dropdown.test.tsx +202 -1
- package/core/components/atoms/dropdown/__tests__/Option.test.tsx +3 -0
- package/core/components/atoms/message/__stories__/CustomDescription.tsx +25 -0
- package/core/components/atoms/metaList/Meta.tsx +3 -1
- package/core/components/atoms/metaList/__tests__/MetaList.test.tsx +30 -36
- package/core/components/atoms/metricInput/MetricInput.tsx +2 -2
- package/core/components/atoms/outsideClick/__stories__/index.story.tsx +1 -1
- package/core/components/atoms/radio/Radio.tsx +7 -10
- package/core/components/atoms/radio/__tests__/Radio.test.tsx +13 -7
- package/core/components/css-utilities/Align/Align.story.tsx +1 -1
- package/core/components/css-utilities/Background/Background.story.tsx +1 -1
- package/core/components/css-utilities/Border/Border.story.tsx +128 -0
- package/core/components/css-utilities/Display/Display.story.tsx +1 -1
- package/core/components/css-utilities/Flex/Flex.story.tsx +1 -1
- package/core/components/css-utilities/Miscellaneous/Miscellaneous.story.tsx +1 -1
- package/core/components/css-utilities/Overflow/Overflow.story.tsx +1 -1
- package/core/components/css-utilities/Position/Position.story.tsx +1 -1
- package/core/components/css-utilities/Sizing/Sizing.story.tsx +1 -1
- package/core/components/css-utilities/Spacing/Spacing.story.tsx +1 -1
- package/core/components/molecules/chatMessage/__tests__/ChatMessage.test.tsx +20 -46
- package/core/components/molecules/dropzone/__tests__/Dropzone.test.tsx +47 -111
- package/core/components/molecules/dropzone/__tests__/Utilities.test.tsx +13 -13
- package/core/components/molecules/editableChipInput/EditableChipInput.tsx +3 -1
- package/core/components/molecules/editableInput/EditableInput.tsx +5 -3
- package/core/components/molecules/editableInput/__stories__/variants/Uncontrolled.story.tsx +1 -1
- package/core/components/molecules/editableInput/__tests__/EditableInput.test.tsx +1 -3
- package/core/components/molecules/emptyState/_tests_/EmptyState.test.tsx +3 -7
- package/core/components/molecules/fileUploader/FileUploaderItem.tsx +13 -2
- package/core/components/molecules/fileUploader/__stories__/index.story.tsx +156 -21
- package/core/components/molecules/fileUploader/__tests__/FileUploader.test.tsx +21 -80
- package/core/components/molecules/fileUploader/__tests__/FileUploaderList.test.tsx +9 -40
- package/core/components/molecules/fullscreenModal/FullscreenModal.tsx +7 -13
- package/core/components/molecules/fullscreenModal/__stories__/Layering.story.tsx +2 -2
- package/core/components/molecules/modal/Modal.tsx +18 -17
- package/core/components/molecules/modal/ModalBody.tsx +1 -1
- package/core/components/molecules/modal/__stories__/Layering.story.tsx +1 -1
- package/core/components/molecules/modal/__stories__/NoFooter.story.tsx +0 -1
- package/core/components/molecules/modal/__stories__/Scrolling.story.tsx +20 -38
- package/core/components/molecules/modal/__tests__/Modal.test.tsx +1 -1
- package/core/components/molecules/sidesheet/Sidesheet.tsx +16 -17
- package/core/components/organisms/choiceList/ChoiceList.tsx +212 -0
- package/core/components/organisms/choiceList/__stories__/Alignment.story.tsx +32 -0
- package/core/components/organisms/choiceList/__stories__/AllowMultiple.story.tsx +23 -0
- package/core/components/organisms/choiceList/__stories__/Controlled.story.tsx +34 -0
- package/core/components/organisms/choiceList/__stories__/index.story.tsx +18 -0
- package/core/components/organisms/choiceList/__tests__/ChoiceList.test.tsx +155 -0
- package/core/components/organisms/choiceList/__tests__/__snapshots__/ChoiceList.test.tsx.snap +3393 -0
- package/core/components/organisms/choiceList/index.tsx +2 -0
- package/core/components/organisms/datePicker/__tests__/DatePicker.test.tsx +136 -46
- package/core/components/organisms/datePicker/__tests__/__snapshots__/DatePicker.test.tsx.snap +2594 -102
- package/core/components/organisms/dateRangePicker/DateRangePicker.tsx +5 -0
- package/core/components/organisms/dateRangePicker/__tests__/DateRangePicker.test.tsx +49 -410
- package/core/components/organisms/dateRangePicker/__tests__/Utilities.test.tsx +39 -0
- package/core/components/organisms/dateRangePicker/__tests__/__snapshots__/DateRangePicker.test.tsx.snap +45390 -2679
- package/core/components/organisms/dateRangePicker/utilities.tsx +2 -5
- package/core/components/organisms/grid/Cell.tsx +5 -4
- package/core/components/organisms/grid/Grid.tsx +1 -1
- package/core/components/organisms/grid/GridCell.tsx +18 -7
- package/core/components/organisms/grid/GridHead.tsx +1 -1
- package/core/components/organisms/grid/GridRow.tsx +5 -12
- package/core/components/organisms/grid/__tests__/Grid.test.tsx +179 -1
- package/core/components/organisms/grid/__tests__/GridCell.test.tsx +218 -0
- package/core/components/organisms/grid/__tests__/__snapshots__/Grid.test.tsx.snap +1024 -0
- package/core/components/organisms/grid/__tests__/rowUtility.test.tsx +62 -0
- package/core/components/organisms/inlineMessage/InlineMessage.tsx +10 -14
- package/core/components/organisms/inlineMessage/__stories__/InlineMessageWithinTable.story.tsx +9 -12
- package/core/components/organisms/inlineMessage/__stories__/variants/Default.story.tsx +2 -4
- package/core/components/organisms/inlineMessage/__stories__/variants/Error.story.tsx +2 -5
- package/core/components/organisms/inlineMessage/__stories__/variants/Info.story.tsx +2 -5
- package/core/components/organisms/inlineMessage/__stories__/variants/Success.story.tsx +2 -5
- package/core/components/organisms/inlineMessage/__stories__/variants/Warning.story.tsx +2 -5
- package/core/components/organisms/inlineMessage/__tests__/InlineMessage.test.tsx +4 -20
- package/core/components/organisms/navigation/VerticalNavigation.tsx +14 -3
- package/core/components/organisms/navigation/__tests__/Navigation.test.tsx +179 -0
- package/core/components/organisms/navigation/__tests__/__snapshots__/Navigation.test.tsx.snap +530 -0
- package/core/components/organisms/table/DraggableDropdown.tsx +1 -0
- package/core/components/organisms/table/Header.tsx +11 -2
- package/core/components/organisms/table/Table.tsx +2 -2
- package/core/components/organisms/table/__stories__/NestedTableWithNestedCard.story.tsx +4 -1
- package/core/components/organisms/table/__stories__/variants/nestedRows.story.tsx +5 -2
- package/core/components/organisms/table/__tests__/Table.test.tsx +292 -0
- package/core/components/organisms/table/__tests__/__snapshots__/Table.test.tsx.snap +349041 -0
- package/core/components/organisms/timePicker/__tests__/TimePicker.test.tsx +15 -66
- package/core/components/patterns/dateRangePicker/withCustomPopover.story.tsx +47 -36
- package/core/index.tsx +1 -1
- package/core/index.type.tsx +1 -0
- package/core/utils/OverlayManager.tsx +1 -3
- package/core/utils/__tests__/__snapshots__/TS.test.tsx.snap +4 -0
- package/core/utils/types.tsx +3 -4
- package/css/dist/index.css +78 -8
- package/css/dist/index.css.map +1 -1
- package/css/src/components/button.css +8 -4
- package/css/src/components/choiceList.css +25 -0
- package/css/src/components/modal.css +1 -2
- package/css/src/utils/border.css +39 -0
- package/dist/core/components/atoms/popperWrapper/PopperWrapper.d.ts +50 -49
- package/dist/core/components/css-utilities/Border/Border.story.d.ts +13 -0
- package/dist/core/components/organisms/choiceList/ChoiceList.d.ts +33 -0
- package/dist/core/components/organisms/choiceList/index.d.ts +2 -0
- package/dist/core/components/organisms/dateRangePicker/utilities.d.ts +2 -2
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.type.d.ts +1 -0
- package/dist/index.esm.js +207 -58
- package/dist/index.js +209 -57
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.br +0 -0
- package/dist/index.umd.js.gz +0 -0
- package/jest.config.js +2 -1
- package/package.json +6 -4
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import * as rowUtility from '../rowUtility';
|
|
2
|
+
|
|
3
|
+
describe('test updateBatchData', () => {
|
|
4
|
+
it('updates data at provided rowIndexes ', () => {
|
|
5
|
+
const data = [{ name: 'name', gender: 'f' }];
|
|
6
|
+
const rowIndexes = [0];
|
|
7
|
+
const dataUpdate = { age: 25 };
|
|
8
|
+
expect(rowUtility.updateBatchData(data, rowIndexes, dataUpdate)).toEqual([{ age: 25, gender: 'f', name: 'name' }]);
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
describe('test translateData', () => {
|
|
12
|
+
it('translate data with title', () => {
|
|
13
|
+
const schema = {
|
|
14
|
+
name: 'name',
|
|
15
|
+
displayName: 'Name',
|
|
16
|
+
};
|
|
17
|
+
const data = { name: 'zara' };
|
|
18
|
+
expect(rowUtility.translateData(schema, data)).toEqual({ name: { title: 'zara' } });
|
|
19
|
+
});
|
|
20
|
+
it('translate data when schema.translate present ', () => {
|
|
21
|
+
const schema = {
|
|
22
|
+
name: 'name',
|
|
23
|
+
displayName: 'Name',
|
|
24
|
+
translate: jest.fn(),
|
|
25
|
+
};
|
|
26
|
+
const data = { name: 'zara' };
|
|
27
|
+
schema.translate.mockReturnValueOnce('sara');
|
|
28
|
+
expect(rowUtility.translateData(schema, data)).toEqual({ name: { title: 'sara' } });
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
describe('test filterData', () => {
|
|
32
|
+
it(' test filterData ', () => {
|
|
33
|
+
const schema = [
|
|
34
|
+
{
|
|
35
|
+
name: 'name',
|
|
36
|
+
displayName: 'Name',
|
|
37
|
+
onFilterChange: jest.fn(),
|
|
38
|
+
},
|
|
39
|
+
];
|
|
40
|
+
const data = [{ name: 'zara', age: 25 }];
|
|
41
|
+
const filterList = { name: ['name'] };
|
|
42
|
+
schema[0].onFilterChange.mockReturnValueOnce({
|
|
43
|
+
age: 1,
|
|
44
|
+
});
|
|
45
|
+
expect(rowUtility.filterData(schema, data, filterList)).toEqual([{ age: 25, name: 'zara' }]);
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
describe('test sortData', () => {
|
|
49
|
+
it(' test sortData ', () => {
|
|
50
|
+
const schema = [
|
|
51
|
+
{
|
|
52
|
+
name: 'name',
|
|
53
|
+
displayName: 'Name',
|
|
54
|
+
},
|
|
55
|
+
];
|
|
56
|
+
const data = [{ name: 'sara' }, { name: 'zara' }];
|
|
57
|
+
expect(rowUtility.sortData(schema, data, [{ name: 'name', type: 'desc' }])).toEqual([
|
|
58
|
+
{ name: 'zara' },
|
|
59
|
+
{ name: 'sara' },
|
|
60
|
+
]);
|
|
61
|
+
});
|
|
62
|
+
});
|
|
@@ -23,17 +23,16 @@ export interface InlineMessageProps extends BaseProps {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
export const InlineMessage = (props: InlineMessageProps) => {
|
|
26
|
-
const {
|
|
27
|
-
appearance,
|
|
28
|
-
className,
|
|
29
|
-
description
|
|
30
|
-
} = props;
|
|
26
|
+
const { appearance, className, description } = props;
|
|
31
27
|
|
|
32
28
|
const baseProps = extractBaseProps(props);
|
|
33
29
|
|
|
34
|
-
const InlineMessageClass = classNames(
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
const InlineMessageClass = classNames(
|
|
31
|
+
{
|
|
32
|
+
['InlineMessage']: true,
|
|
33
|
+
},
|
|
34
|
+
className
|
|
35
|
+
);
|
|
37
36
|
|
|
38
37
|
const IconClass = classNames({
|
|
39
38
|
['InlineMessage-icon']: true,
|
|
@@ -41,7 +40,7 @@ export const InlineMessage = (props: InlineMessageProps) => {
|
|
|
41
40
|
});
|
|
42
41
|
|
|
43
42
|
const DescriptionClass = classNames({
|
|
44
|
-
[`InlineMessage-text--${appearance}`]: appearance
|
|
43
|
+
[`InlineMessage-text--${appearance}`]: appearance,
|
|
45
44
|
});
|
|
46
45
|
|
|
47
46
|
return (
|
|
@@ -55,10 +54,7 @@ export const InlineMessage = (props: InlineMessageProps) => {
|
|
|
55
54
|
/>
|
|
56
55
|
)}
|
|
57
56
|
<div>
|
|
58
|
-
<Text
|
|
59
|
-
data-test="DesignSystem-InlineMessage--Description"
|
|
60
|
-
className={DescriptionClass}
|
|
61
|
-
>
|
|
57
|
+
<Text data-test="DesignSystem-InlineMessage--Description" className={DescriptionClass}>
|
|
62
58
|
{description}
|
|
63
59
|
</Text>
|
|
64
60
|
</div>
|
|
@@ -69,7 +65,7 @@ export const InlineMessage = (props: InlineMessageProps) => {
|
|
|
69
65
|
InlineMessage.displayName = 'InlineMessage';
|
|
70
66
|
InlineMessage.defaultProps = {
|
|
71
67
|
appearance: 'default',
|
|
72
|
-
description: ''
|
|
68
|
+
description: '',
|
|
73
69
|
};
|
|
74
70
|
|
|
75
71
|
export default InlineMessage;
|
package/core/components/organisms/inlineMessage/__stories__/InlineMessageWithinTable.story.tsx
CHANGED
|
@@ -23,11 +23,10 @@ const data = [
|
|
|
23
23
|
lastName: 'Ciric',
|
|
24
24
|
lastUpdated: 'May 19, 2020',
|
|
25
25
|
recipients: 118467,
|
|
26
|
-
}
|
|
26
|
+
},
|
|
27
27
|
];
|
|
28
28
|
|
|
29
29
|
export const InlineMessageWithinTable = () => {
|
|
30
|
-
|
|
31
30
|
const schema: TableProps['schema'] = [
|
|
32
31
|
{
|
|
33
32
|
name: 'name',
|
|
@@ -36,9 +35,9 @@ export const InlineMessageWithinTable = () => {
|
|
|
36
35
|
cellType: 'WITH_META_LIST',
|
|
37
36
|
translate: (a) => ({
|
|
38
37
|
title: a.name,
|
|
39
|
-
metaList: [`${a.recipients} recipients`]
|
|
38
|
+
metaList: [`${a.recipients} recipients`],
|
|
40
39
|
}),
|
|
41
|
-
sorting: false
|
|
40
|
+
sorting: false,
|
|
42
41
|
},
|
|
43
42
|
{
|
|
44
43
|
name: 'lastUpdated',
|
|
@@ -51,10 +50,8 @@ export const InlineMessageWithinTable = () => {
|
|
|
51
50
|
displayName: 'Message',
|
|
52
51
|
sorting: false,
|
|
53
52
|
width: '40%',
|
|
54
|
-
cellRenderer: () =>
|
|
55
|
-
|
|
56
|
-
)
|
|
57
|
-
}
|
|
53
|
+
cellRenderer: () => <InlineMessage appearance="info" description="Patient profile updated." />,
|
|
54
|
+
},
|
|
58
55
|
];
|
|
59
56
|
|
|
60
57
|
return (
|
|
@@ -66,7 +63,7 @@ export const InlineMessageWithinTable = () => {
|
|
|
66
63
|
schema={schema}
|
|
67
64
|
withHeader={false}
|
|
68
65
|
headerOptions={{
|
|
69
|
-
withSearch: false
|
|
66
|
+
withSearch: false,
|
|
70
67
|
}}
|
|
71
68
|
/>
|
|
72
69
|
</Card>
|
|
@@ -133,7 +130,7 @@ export default {
|
|
|
133
130
|
docs: {
|
|
134
131
|
docPage: {
|
|
135
132
|
customCode,
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
},
|
|
139
136
|
};
|
|
@@ -5,14 +5,12 @@ import { InlineMessage, Row, Column } from '@/index';
|
|
|
5
5
|
export const defaultMessage = () => (
|
|
6
6
|
<Row>
|
|
7
7
|
<Column size="4">
|
|
8
|
-
<InlineMessage
|
|
9
|
-
description="Create a strong, unique password."
|
|
10
|
-
/>
|
|
8
|
+
<InlineMessage description="Create a strong, unique password." />
|
|
11
9
|
</Column>
|
|
12
10
|
</Row>
|
|
13
11
|
);
|
|
14
12
|
|
|
15
13
|
export default {
|
|
16
14
|
title: 'Components/InlineMessage/Variants/Default Message',
|
|
17
|
-
component: InlineMessage
|
|
15
|
+
component: InlineMessage,
|
|
18
16
|
};
|
|
@@ -5,15 +5,12 @@ import { InlineMessage, Row, Column } from '@/index';
|
|
|
5
5
|
export const alertMessage = () => (
|
|
6
6
|
<Row>
|
|
7
7
|
<Column size="4">
|
|
8
|
-
<InlineMessage
|
|
9
|
-
appearance="alert"
|
|
10
|
-
description="Inline message goes here."
|
|
11
|
-
/>
|
|
8
|
+
<InlineMessage appearance="alert" description="Inline message goes here." />
|
|
12
9
|
</Column>
|
|
13
10
|
</Row>
|
|
14
11
|
);
|
|
15
12
|
|
|
16
13
|
export default {
|
|
17
14
|
title: 'Components/InlineMessage/Variants/Alert Message',
|
|
18
|
-
component: InlineMessage
|
|
15
|
+
component: InlineMessage,
|
|
19
16
|
};
|
|
@@ -5,15 +5,12 @@ import { InlineMessage, Row, Column } from '@/index';
|
|
|
5
5
|
export const infoMessage = () => (
|
|
6
6
|
<Row>
|
|
7
7
|
<Column size="4">
|
|
8
|
-
<InlineMessage
|
|
9
|
-
appearance="info"
|
|
10
|
-
description="There are two new referral requests."
|
|
11
|
-
/>
|
|
8
|
+
<InlineMessage appearance="info" description="There are two new referral requests." />
|
|
12
9
|
</Column>
|
|
13
10
|
</Row>
|
|
14
11
|
);
|
|
15
12
|
|
|
16
13
|
export default {
|
|
17
14
|
title: 'Components/InlineMessage/Variants/Info Message',
|
|
18
|
-
component: InlineMessage
|
|
15
|
+
component: InlineMessage,
|
|
19
16
|
};
|
|
@@ -5,15 +5,12 @@ import { InlineMessage, Row, Column } from '@/index';
|
|
|
5
5
|
export const successMessage = () => (
|
|
6
6
|
<Row>
|
|
7
7
|
<Column size="4">
|
|
8
|
-
<InlineMessage
|
|
9
|
-
appearance="success"
|
|
10
|
-
description="Inline message goes here."
|
|
11
|
-
/>
|
|
8
|
+
<InlineMessage appearance="success" description="Inline message goes here." />
|
|
12
9
|
</Column>
|
|
13
10
|
</Row>
|
|
14
11
|
);
|
|
15
12
|
|
|
16
13
|
export default {
|
|
17
14
|
title: 'Components/InlineMessage/Variants/Success Message',
|
|
18
|
-
component: InlineMessage
|
|
15
|
+
component: InlineMessage,
|
|
19
16
|
};
|
|
@@ -4,15 +4,12 @@ import { InlineMessage, Row, Column } from '@/index';
|
|
|
4
4
|
export const warningMessage = () => (
|
|
5
5
|
<Row>
|
|
6
6
|
<Column size="4">
|
|
7
|
-
<InlineMessage
|
|
8
|
-
appearance="warning"
|
|
9
|
-
description="Inline message goes here."
|
|
10
|
-
/>
|
|
7
|
+
<InlineMessage appearance="warning" description="Inline message goes here." />
|
|
11
8
|
</Column>
|
|
12
9
|
</Row>
|
|
13
10
|
);
|
|
14
11
|
|
|
15
12
|
export default {
|
|
16
13
|
title: 'Components/InlineMessage/Variants/Warning Message',
|
|
17
|
-
component: InlineMessage
|
|
14
|
+
component: InlineMessage,
|
|
18
15
|
};
|
|
@@ -4,31 +4,21 @@ import { testHelper, filterUndefined, valueHelper, testMessageHelper } from '@/u
|
|
|
4
4
|
import { Appearance, InlineMessage } from '../InlineMessage';
|
|
5
5
|
import { InlineMessageProps as Props } from '@/index.type';
|
|
6
6
|
|
|
7
|
-
const appearance: Appearance[] = [
|
|
8
|
-
'default',
|
|
9
|
-
'alert',
|
|
10
|
-
'info',
|
|
11
|
-
'success',
|
|
12
|
-
'warning'
|
|
13
|
-
];
|
|
7
|
+
const appearance: Appearance[] = ['default', 'alert', 'info', 'success', 'warning'];
|
|
14
8
|
|
|
15
9
|
const description = 'Inline Message here.';
|
|
16
10
|
|
|
17
11
|
describe('InlineMessage component', () => {
|
|
18
12
|
const mapper: Record<string, any> = {
|
|
19
13
|
appearance: valueHelper(appearance, { required: true, iterate: true }),
|
|
20
|
-
description: valueHelper(description, { required: true })
|
|
14
|
+
description: valueHelper(description, { required: true }),
|
|
21
15
|
};
|
|
22
16
|
|
|
23
17
|
const testFunc = (props: Record<string, any>): void => {
|
|
24
18
|
const attr = filterUndefined(props) as Props;
|
|
25
19
|
|
|
26
20
|
it(testMessageHelper(attr), () => {
|
|
27
|
-
const { baseElement } = render(
|
|
28
|
-
<InlineMessage
|
|
29
|
-
{...attr}
|
|
30
|
-
/>
|
|
31
|
-
);
|
|
21
|
+
const { baseElement } = render(<InlineMessage {...attr} />);
|
|
32
22
|
expect(baseElement).toMatchSnapshot();
|
|
33
23
|
});
|
|
34
24
|
};
|
|
@@ -53,7 +43,6 @@ describe('InlineMessage component with prop:appearance', () => {
|
|
|
53
43
|
});
|
|
54
44
|
|
|
55
45
|
describe('InlineMessage component ', () => {
|
|
56
|
-
|
|
57
46
|
it('check for icon when appearance:default', () => {
|
|
58
47
|
render(<InlineMessage appearance="default" description={description} />);
|
|
59
48
|
const IconComponent = screen.queryByText('DesignSystem-InlineMessage--Icon');
|
|
@@ -61,12 +50,7 @@ describe('InlineMessage component ', () => {
|
|
|
61
50
|
});
|
|
62
51
|
|
|
63
52
|
it('render component when appearance is not default', () => {
|
|
64
|
-
const { getByTestId } = render(
|
|
65
|
-
<InlineMessage
|
|
66
|
-
appearance="info"
|
|
67
|
-
description={description}
|
|
68
|
-
/>
|
|
69
|
-
);
|
|
53
|
+
const { getByTestId } = render(<InlineMessage appearance="info" description={description} />);
|
|
70
54
|
const descriptionID = getByTestId('DesignSystem-InlineMessage--Description');
|
|
71
55
|
expect(descriptionID).toBeInTheDocument();
|
|
72
56
|
expect(descriptionID.textContent).toMatch(description);
|
|
@@ -136,10 +136,15 @@ export const VerticalNavigation = (props: VerticalNavigationProps) => {
|
|
|
136
136
|
});
|
|
137
137
|
|
|
138
138
|
return (
|
|
139
|
-
<div key={index}>
|
|
140
|
-
<div
|
|
139
|
+
<div key={index} data-test="DesignSystem-Navigation-VerticalNavigation--menuWrapper">
|
|
140
|
+
<div
|
|
141
|
+
data-test="DesignSystem-Navigation-VerticalNavigation--menuItem"
|
|
142
|
+
className={menuClasses}
|
|
143
|
+
onClick={() => onClickHandler(menu)}
|
|
144
|
+
>
|
|
141
145
|
{menu.icon && (
|
|
142
146
|
<Icon
|
|
147
|
+
data-test="DesignSystem-Navigation-VerticalNavigation--menuIcon"
|
|
143
148
|
className={menuIconClasses}
|
|
144
149
|
name={menu.icon}
|
|
145
150
|
appearance={getIconAppearance(activeMenuIcon, menu.disabled)}
|
|
@@ -152,6 +157,7 @@ export const VerticalNavigation = (props: VerticalNavigationProps) => {
|
|
|
152
157
|
</span>
|
|
153
158
|
{menu.subMenu && menu.subMenu.length > 0 && (
|
|
154
159
|
<Icon
|
|
160
|
+
data-test="DesignSystem-Navigation-VerticalNavigation--expandedSubMenuIcon"
|
|
155
161
|
className="mx-4"
|
|
156
162
|
name={menuState[menu.name] ? 'keyboard_arrow_up' : 'keyboard_arrow_down'}
|
|
157
163
|
appearance="subtle"
|
|
@@ -173,7 +179,12 @@ export const VerticalNavigation = (props: VerticalNavigationProps) => {
|
|
|
173
179
|
});
|
|
174
180
|
|
|
175
181
|
return (
|
|
176
|
-
<div
|
|
182
|
+
<div
|
|
183
|
+
data-test="DesignSystem-Navigation-VerticalNavigation--subMenu"
|
|
184
|
+
key={ind}
|
|
185
|
+
className={subMenuClasses}
|
|
186
|
+
onClick={() => onClickHandler(subMenu)}
|
|
187
|
+
>
|
|
177
188
|
<Text appearance={getTextAppearance(isActive, subMenu.disabled)}>{subMenu.label}</Text>
|
|
178
189
|
</div>
|
|
179
190
|
);
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { render, fireEvent } from '@testing-library/react';
|
|
3
|
+
import Navigation, { NavigationProps as Props, Align, Menu } from '../Navigation';
|
|
4
|
+
import { testHelper, filterUndefined, valueHelper, testMessageHelper } from '@/utils/testHelper';
|
|
5
|
+
|
|
6
|
+
const onClick = jest.fn();
|
|
7
|
+
const onToggle = jest.fn();
|
|
8
|
+
const align: Align[] = ['left', 'center'];
|
|
9
|
+
|
|
10
|
+
const menus: Menu[] = [
|
|
11
|
+
{
|
|
12
|
+
name: 'tab1',
|
|
13
|
+
label: 'Tab #1',
|
|
14
|
+
count: 1,
|
|
15
|
+
icon: 'event',
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name: 'tab2',
|
|
19
|
+
label: 'Tab #2',
|
|
20
|
+
count: 2,
|
|
21
|
+
subMenu: [
|
|
22
|
+
{
|
|
23
|
+
name: 'tab2child1',
|
|
24
|
+
label: 'tab2child1',
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: 'tab2child2',
|
|
28
|
+
label: 'tab2child2',
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: 'tab3',
|
|
34
|
+
label: 'Tab #3',
|
|
35
|
+
count: 3,
|
|
36
|
+
subMenu: [
|
|
37
|
+
{
|
|
38
|
+
name: 'tab3child1',
|
|
39
|
+
label: 'tab3child1',
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
];
|
|
44
|
+
|
|
45
|
+
describe('Navigation component', () => {
|
|
46
|
+
const mapper = {
|
|
47
|
+
type: valueHelper('horizontal', { required: true }),
|
|
48
|
+
align: valueHelper(align, { required: true, iterate: true }),
|
|
49
|
+
menus: valueHelper(menus, { required: true }),
|
|
50
|
+
active: valueHelper(true, { required: true }),
|
|
51
|
+
onClick: valueHelper(onClick, { required: true }),
|
|
52
|
+
onToggle: valueHelper(onToggle, { required: true }),
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const testFunc = (props: Record<string, any>): void => {
|
|
56
|
+
const attr = filterUndefined(props) as Props;
|
|
57
|
+
|
|
58
|
+
it(testMessageHelper(attr), () => {
|
|
59
|
+
const tree = render(<Navigation {...attr} />);
|
|
60
|
+
expect(tree).toMatchSnapshot();
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
testHelper(mapper, testFunc);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
describe('Navigation component', () => {
|
|
68
|
+
const mapper = {
|
|
69
|
+
type: valueHelper('vertical', { required: true }),
|
|
70
|
+
menus: valueHelper(menus, { required: true }),
|
|
71
|
+
autoCollapse: valueHelper(false, { required: true }),
|
|
72
|
+
expanded: valueHelper(false, { required: true }),
|
|
73
|
+
rounded: valueHelper(true, { required: true }),
|
|
74
|
+
onClick: valueHelper(onClick, { required: true }),
|
|
75
|
+
onToggle: valueHelper(onToggle, { required: true }),
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const testFunc = (props: Record<string, any>): void => {
|
|
79
|
+
const attr = filterUndefined(props) as Props;
|
|
80
|
+
|
|
81
|
+
it(testMessageHelper(attr), () => {
|
|
82
|
+
const tree = render(<Navigation {...attr} />);
|
|
83
|
+
expect(tree).toMatchSnapshot();
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
testHelper(mapper, testFunc);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
describe('Navigation component', () => {
|
|
91
|
+
it('render horizontal nav when no type is passed', () => {
|
|
92
|
+
const { getAllByTestId } = render(<Navigation menus={menus} />);
|
|
93
|
+
expect(getAllByTestId('DesignSystem-HorizontalNav')[0]).toHaveClass('HorizontalNav-menu');
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('renders vertical nav when vertical type is passed', () => {
|
|
97
|
+
const { getAllByTestId } = render(<Navigation menus={menus} type="vertical" />);
|
|
98
|
+
expect(getAllByTestId('DesignSystem-Navigation-VerticalNavigation--menuWrapper')).toBeTruthy();
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
describe('Navigation component', () => {
|
|
103
|
+
it('render vertical nav when active is true', () => {
|
|
104
|
+
const { container } = render(<Navigation menus={menus} type="vertical" active={{ name: 'tab1' }} />);
|
|
105
|
+
expect(container.getElementsByClassName('Navigation-menu--active').length).toBe(1);
|
|
106
|
+
});
|
|
107
|
+
it('render vertical nav when active is not passed', () => {
|
|
108
|
+
const { container } = render(<Navigation menus={menus} type="vertical" />);
|
|
109
|
+
expect(container.getElementsByClassName('Navigation-menu--active').length).toBe(0);
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
describe('VerticalNavigation component', () => {
|
|
114
|
+
it('render vertical nav when subMenu is passed and menu tab is active', () => {
|
|
115
|
+
const { getAllByTestId } = render(<Navigation menus={menus} type="vertical" active={{ name: 'tab2' }} />);
|
|
116
|
+
expect(getAllByTestId('DesignSystem-Navigation-VerticalNavigation--expandedSubMenuIcon')[0]).toHaveTextContent(
|
|
117
|
+
'keyboard_arrow_up_round'
|
|
118
|
+
);
|
|
119
|
+
expect(getAllByTestId('DesignSystem-Navigation-VerticalNavigation--expandedSubMenuIcon')[1]).toHaveTextContent(
|
|
120
|
+
'keyboard_arrow_down_round'
|
|
121
|
+
);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it('render vertical nav when subMenu is not passed and menu tab is active', () => {
|
|
125
|
+
const { getAllByTestId } = render(<Navigation menus={menus} type="vertical" active={{ name: 'tab1' }} />);
|
|
126
|
+
expect(getAllByTestId('DesignSystem-Navigation-VerticalNavigation--menuItem')[0]).toHaveClass(
|
|
127
|
+
'Navigation-menu--active'
|
|
128
|
+
);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it('render vertical nav menu is expanded and rounded', () => {
|
|
132
|
+
const { getAllByTestId } = render(<Navigation menus={menus} type="vertical" rounded={true} />);
|
|
133
|
+
expect(getAllByTestId('DesignSystem-Navigation-VerticalNavigation--menuItem')[0]).toHaveClass(
|
|
134
|
+
'Navigation-menu--rounded'
|
|
135
|
+
);
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it('render vertical nav menu is has icon', () => {
|
|
139
|
+
const { getByTestId } = render(<Navigation menus={menus} type="vertical" />);
|
|
140
|
+
expect(getByTestId('DesignSystem-Navigation-VerticalNavigation--menuIcon')).toHaveClass('Navigation-menuIcon');
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
it('render vertical nav menu is has icon and menu is active', () => {
|
|
144
|
+
const { getByTestId } = render(<Navigation menus={menus} type="vertical" active={{ name: 'tab1' }} />);
|
|
145
|
+
expect(getByTestId('DesignSystem-Navigation-VerticalNavigation--menuIcon')).toHaveClass(
|
|
146
|
+
'Navigation-menuIcon--active'
|
|
147
|
+
);
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
describe('Vertical Navigation component prop: onClick', () => {
|
|
152
|
+
it('renders vertical nav component with onClick without submenu ', () => {
|
|
153
|
+
const { getAllByTestId } = render(<Navigation onClick={onClick} menus={menus} type="vertical" />);
|
|
154
|
+
const menuClicked = getAllByTestId('DesignSystem-Navigation-VerticalNavigation--menuItem')[0];
|
|
155
|
+
fireEvent.click(menuClicked);
|
|
156
|
+
expect(onClick).toHaveBeenCalledTimes(1);
|
|
157
|
+
expect(onClick).toHaveBeenCalledWith(menus[0]);
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
it('renders vertical nav component with onClick with subMenu and expanded false', () => {
|
|
161
|
+
const { getAllByTestId } = render(<Navigation onClick={onClick} menus={menus} type="vertical" expanded={false} />);
|
|
162
|
+
const menuClicked = getAllByTestId('DesignSystem-Navigation-VerticalNavigation--menuItem')[2];
|
|
163
|
+
fireEvent.click(menuClicked);
|
|
164
|
+
expect(onClick).toHaveBeenCalled();
|
|
165
|
+
expect(onClick).toHaveBeenCalledWith({ label: 'tab3child1', name: 'tab3child1' });
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
it('renders vertical nav component with onClick on Submenu ', () => {
|
|
169
|
+
const { getAllByTestId } = render(
|
|
170
|
+
<Navigation onClick={onClick} menus={menus} type="vertical" active={{ name: 'tab3' }} autoCollapse={false} />
|
|
171
|
+
);
|
|
172
|
+
const menuClicked = getAllByTestId('DesignSystem-Navigation-VerticalNavigation--subMenu')[0];
|
|
173
|
+
fireEvent.click(menuClicked);
|
|
174
|
+
expect(onClick).toHaveBeenCalledWith({
|
|
175
|
+
name: 'tab3child1',
|
|
176
|
+
label: 'tab3child1',
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
});
|