inactivePlugins.spec.jsx 983 B

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