inactivePlugins.spec.jsx 951 B

123456789101112131415161718192021222324252627
  1. import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  2. import InactivePlugins from 'sentry/components/inactivePlugins';
  3. describe('InactivePlugins', function () {
  4. it('renders null when no plugins', function () {
  5. const {container} = render(
  6. <InactivePlugins plugins={[]} onEnablePlugin={() => {}} />
  7. );
  8. expect(container).toBeEmptyDOMElement();
  9. });
  10. it('renders plugins list', function () {
  11. const {container} = render(
  12. <InactivePlugins onEnablePlugin={() => {}} plugins={TestStubs.Plugins()} />
  13. );
  14. expect(container).toSnapshot();
  15. });
  16. it('enables a plugin', function () {
  17. const enableFn = jest.fn();
  18. const plugins = TestStubs.Plugins();
  19. render(<InactivePlugins onEnablePlugin={enableFn} plugins={plugins} />);
  20. userEvent.click(screen.getByRole('button', {name: plugins[0].name}));
  21. expect(enableFn).toHaveBeenCalledWith(expect.objectContaining(plugins[0]));
  22. });
  23. });