|
@@ -1,4 +1,4 @@
|
|
|
-import {act, mountWithTheme} from 'sentry-test/reactTestingLibrary';
|
|
|
+import {act, renderHook} from '@testing-library/react-hooks';
|
|
|
|
|
|
import TeamStore from 'app/stores/teamStore';
|
|
|
import {useLegacyStore} from 'app/stores/useLegacyStore';
|
|
@@ -7,21 +7,15 @@ describe('useLegacyStore', () => {
|
|
|
// @ts-expect-error
|
|
|
const team = TestStubs.Team();
|
|
|
|
|
|
- function TestComponent() {
|
|
|
- const teamStore = useLegacyStore(TeamStore);
|
|
|
- return <div>Teams: {teamStore.teams.length}</div>;
|
|
|
- }
|
|
|
-
|
|
|
- afterEach(() => {
|
|
|
- TeamStore.reset();
|
|
|
- });
|
|
|
+ beforeEach(() => void TeamStore.reset());
|
|
|
|
|
|
it('should update on change to store', () => {
|
|
|
- const wrapper = mountWithTheme(<TestComponent />);
|
|
|
- expect(wrapper.getByText('Teams: 0')).toBeTruthy();
|
|
|
+ const {result} = renderHook(() => useLegacyStore(TeamStore));
|
|
|
+
|
|
|
+ expect(result.current.teams).toEqual([]);
|
|
|
|
|
|
act(() => TeamStore.loadInitialData([team]));
|
|
|
|
|
|
- expect(wrapper.getByText('Teams: 1')).toBeTruthy();
|
|
|
+ expect(result.current.teams).toEqual([team]);
|
|
|
});
|
|
|
});
|