⚝
One Hat Cyber Team
⚝
Your IP:
216.73.217.4
Server IP:
41.128.143.86
Server:
Linux host.raqmix.cloud 6.8.0-1025-azure #30~22.04.1-Ubuntu SMP Wed Mar 12 15:28:20 UTC 2025 x86_64
Server Software:
Apache
PHP Version:
8.3.23
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
usr
/
share
/
grafana
/
public
/
app
/
features
/
org
/
View File Name :
OrgProfile.test.tsx
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(
)).not.toThrow(); }); it('should show the current org name', () => { render(
); const orgNameInput = screen.getByLabelText('Organization name'); expect(orgNameInput).toHaveValue('Main org'); }); it('can update the current org name', async () => { render(
); 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'); }); });