Files
grafana/public/app/features/org/OrgProfile.test.tsx
Ashley Harrison 47f8717149 React: Use new JSX transform (#88802)
* update eslint, tsconfig + esbuild to handle new jsx transform

* remove thing that breaks the new jsx transform

* remove react imports

* adjust grafana-icons build

* is this the correct syntax?

* try this

* well this was much easier than expected...

* change grafana-plugin-configs webpack config

* fixes

* fix lockfile

* fix 2 more violations

* use path.resolve instead of require.resolve

* remove react import

* fix react imports

* more fixes

* remove React import

* remove import React from docs

* remove another react import
2024-06-25 12:43:47 +01:00

47 lines
1.2 KiB
TypeScript

import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import OrgProfile, { Props } from './OrgProfile';
jest.mock('app/core/core', () => {
return {
contextSrv: {
hasPermission: () => true,
},
};
});
describe('OrgProfile', () => {
const props: Props = {
orgName: 'Main org',
onSubmit: jest.fn(),
};
it('should render without crashing', () => {
expect(() => render(<OrgProfile {...props} />)).not.toThrow();
});
it('should show the current org name', () => {
render(<OrgProfile {...props} />);
const orgNameInput = screen.getByLabelText('Organization name');
expect(orgNameInput).toHaveValue('Main org');
});
it('can update the current org name', async () => {
render(<OrgProfile {...props} />);
const orgNameInput = screen.getByLabelText('Organization name');
const submitButton = screen.getByRole('button', { name: 'Update organization name' });
expect(orgNameInput).toHaveValue('Main org');
await userEvent.clear(orgNameInput);
await userEvent.type(orgNameInput, 'New org name');
await userEvent.click(submitButton);
expect(props.onSubmit).toHaveBeenCalledWith('New org name');
});
});