@openmrs/esm-patient-common-lib 12.3.5-pre.12608 → 12.3.5-pre.12622
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/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/workspace-back-button/index.ts +1 -0
- package/src/workspace-back-button/workspace-back-button.component.tsx +20 -0
- package/src/workspace-back-button/workspace-back-button.scss +15 -0
- package/src/workspace-back-button/workspace-back-button.test.tsx +21 -0
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './workspace-back-button.component';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React, { type MouseEventHandler } from 'react';
|
|
2
|
+
import { Button } from '@carbon/react';
|
|
3
|
+
import { ArrowLeftIcon } from '@openmrs/esm-framework';
|
|
4
|
+
import styles from './workspace-back-button.scss';
|
|
5
|
+
|
|
6
|
+
export interface WorkspaceBackButtonProps {
|
|
7
|
+
label: string;
|
|
8
|
+
onClick: MouseEventHandler<HTMLButtonElement>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const WorkspaceBackButton: React.FC<WorkspaceBackButtonProps> = ({ label, onClick }) => {
|
|
12
|
+
return (
|
|
13
|
+
<div className={styles.backButton}>
|
|
14
|
+
<Button kind="ghost" size="sm" onClick={onClick}>
|
|
15
|
+
<ArrowLeftIcon size={16} />
|
|
16
|
+
<span>{label}</span>
|
|
17
|
+
</Button>
|
|
18
|
+
</div>
|
|
19
|
+
);
|
|
20
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
3
|
+
import userEvent from '@testing-library/user-event';
|
|
4
|
+
import { render, screen } from '@testing-library/react';
|
|
5
|
+
import { WorkspaceBackButton } from './workspace-back-button.component';
|
|
6
|
+
|
|
7
|
+
describe('WorkspaceBackButton', () => {
|
|
8
|
+
it('renders a button with the provided label and triggers onClick', async () => {
|
|
9
|
+
const user = userEvent.setup();
|
|
10
|
+
const handleClick = vi.fn();
|
|
11
|
+
|
|
12
|
+
render(<WorkspaceBackButton label="Back to order basket" onClick={handleClick} />);
|
|
13
|
+
|
|
14
|
+
const button = screen.getByRole('button', { name: /back to order basket/i });
|
|
15
|
+
expect(button).toBeInTheDocument();
|
|
16
|
+
expect(screen.getByText('Back to order basket')).toBeInTheDocument();
|
|
17
|
+
|
|
18
|
+
await user.click(button);
|
|
19
|
+
expect(handleClick).toHaveBeenCalledTimes(1);
|
|
20
|
+
});
|
|
21
|
+
});
|