projectPluginRow.spec.tsx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  2. import ProjectPluginRow from 'sentry/views/settings/projectPlugins/projectPluginRow';
  3. describe('ProjectPluginRow', function () {
  4. const plugin = TestStubs.Plugin();
  5. const org = TestStubs.Organization({access: ['project:write']});
  6. const project = TestStubs.Project();
  7. const params = {orgId: org.slug, projectId: project.slug};
  8. const routerContext = TestStubs.routerContext([{organization: org, project}]);
  9. it('renders', function () {
  10. render(<ProjectPluginRow {...params} {...plugin} project={project} />, {
  11. context: routerContext,
  12. });
  13. });
  14. it('calls `onChange` when clicked', async function () {
  15. const onChange = jest.fn();
  16. render(
  17. <ProjectPluginRow {...params} {...plugin} onChange={onChange} project={project} />,
  18. {context: routerContext}
  19. );
  20. await userEvent.click(screen.getByRole('checkbox'));
  21. expect(onChange).toHaveBeenCalledWith('amazon-sqs', true);
  22. });
  23. it('can not enable/disable or configure plugin without `project:write`', async function () {
  24. const onChange = jest.fn();
  25. render(
  26. <ProjectPluginRow {...params} {...plugin} onChange={onChange} project={project} />,
  27. {
  28. organization: TestStubs.Organization({access: []}),
  29. }
  30. );
  31. await userEvent.click(screen.getByRole('checkbox'));
  32. expect(onChange).not.toHaveBeenCalled();
  33. });
  34. });