123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- import {render} from 'sentry-test/reactTestingLibrary';
- import SentryAppComponentsStore from 'sentry/stores/sentryAppComponentsStore';
- import withSentryAppComponents from 'sentry/utils/withSentryAppComponents';
- describe('withSentryAppComponents HoC', function () {
- beforeEach(() => {
- SentryAppComponentsStore.init();
- });
- it('handles components without a type', function () {
- const MyComponent = jest.fn(() => null);
- const Container = withSentryAppComponents(MyComponent);
- render(<Container />);
- expect(MyComponent).toHaveBeenCalledWith({components: []}, {});
- MyComponent.mockClear();
- SentryAppComponentsStore.loadComponents([
- {type: 'some-type'},
- {type: 'another-type'},
- ]);
- expect(MyComponent).toHaveBeenCalledWith(
- {components: [{type: 'some-type'}, {type: 'another-type'}]},
- {}
- );
- });
- it('handles components of a certain type', function () {
- const MyComponent = jest.fn(() => null);
- const Container = withSentryAppComponents(MyComponent, {componentType: 'some-type'});
- render(<Container />);
- expect(MyComponent).toHaveBeenCalledWith({components: []}, {});
- SentryAppComponentsStore.loadComponents([
- {type: 'some-type'},
- {type: 'another-type'},
- ]);
- expect(MyComponent).toHaveBeenCalledWith({components: [{type: 'some-type'}]}, {});
- });
- });
|