The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/public/app/features/org/OrgProfile.test.tsx

47 lines
1.2 KiB

import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import React from 'react';
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');
});
});