Commit e1408b36 authored by Eduardo Sanz García's avatar Eduardo Sanz García Committed by Eduardo

`useRootThread` Preact hook: convert to named export

parent 4157859d
......@@ -2,7 +2,7 @@ import { useEffect, useState } from 'preact/hooks';
import { useStoreProxy } from '../store/use-store';
import { withServices } from '../service-context';
import useRootThread from './hooks/use-root-thread';
import { useRootThread } from './hooks/use-root-thread';
import ThreadList from './ThreadList';
import SidebarContentError from './SidebarContentError';
......
......@@ -5,7 +5,7 @@ import { useMemo } from 'preact/hooks';
import { countVisible } from '../helpers/thread';
import { useStoreProxy } from '../store/use-store';
import useRootThread from './hooks/use-root-thread';
import { useRootThread } from './hooks/use-root-thread';
/**
* @typedef {import('../helpers/build-thread').Thread} Thread
......
import { Spinner } from '@hypothesis/frontend-shared';
import useRootThread from './hooks/use-root-thread';
import { useRootThread } from './hooks/use-root-thread';
import { countVisible } from '../helpers/thread';
/**
......
......@@ -9,7 +9,7 @@ import { useStoreProxy } from '../store/use-store';
import NotebookFilters from './NotebookFilters';
import NotebookResultCount from './NotebookResultCount';
import PaginatedThreadList from './PaginatedThreadList';
import useRootThread from './hooks/use-root-thread';
import { useRootThread } from './hooks/use-root-thread';
/**
* @typedef NotebookViewProps
......
import { useEffect, useRef } from 'preact/hooks';
import useRootThread from './hooks/use-root-thread';
import { useRootThread } from './hooks/use-root-thread';
import { withServices } from '../service-context';
import { useStoreProxy } from '../store/use-store';
import { tabForAnnotation } from '../helpers/tabs';
......
......@@ -2,7 +2,7 @@ import { useCallback, useEffect } from 'preact/hooks';
import * as searchFilter from '../util/search-filter';
import { withServices } from '../service-context';
import useRootThread from './hooks/use-root-thread';
import { useRootThread } from './hooks/use-root-thread';
import { useStoreProxy } from '../store/use-store';
import ThreadList from './ThreadList';
......
import { mount } from 'enzyme';
import useRootThread, { $imports } from '../use-root-thread';
import { useRootThread, $imports } from '../use-root-thread';
describe('sidebar/components/hooks/use-root-thread', () => {
let fakeStore;
......
......@@ -11,7 +11,7 @@ import { threadAnnotations } from '../../helpers/thread-annotations';
*
* @return {Thread}
*/
export default function useRootThread() {
export function useRootThread() {
const store = useStoreProxy();
const annotations = store.allAnnotations();
const query = store.filterQuery();
......
......@@ -2,7 +2,6 @@ import { mount } from 'enzyme';
import { waitFor } from '../../../test-util/wait';
import { mockImportedComponents } from '../../../test-util/mock-imported-components';
import AnnotationView, { $imports } from '../AnnotationView';
describe('AnnotationView', () => {
......@@ -32,7 +31,7 @@ describe('AnnotationView', () => {
$imports.$mock(mockImportedComponents());
$imports.$mock({
'./hooks/use-root-thread': fakeUseRootThread,
'./hooks/use-root-thread': { useRootThread: fakeUseRootThread },
'../store/use-store': { useStoreProxy: () => fakeStore },
});
});
......
import { mount } from 'enzyme';
import FilterStatus, { $imports } from '../FilterStatus';
import { mockImportedComponents } from '../../../test-util/mock-imported-components';
import FilterStatus, { $imports } from '../FilterStatus';
function getFilterState() {
return {
......@@ -53,7 +52,7 @@ describe('FilterStatus', () => {
$imports.$mock(mockImportedComponents());
$imports.$mock({
'./hooks/use-root-thread': fakeUseRootThread,
'./hooks/use-root-thread': { useRootThread: fakeUseRootThread },
'../store/use-store': { useStoreProxy: () => fakeStore },
'../helpers/thread': fakeThreadUtil,
});
......
......@@ -26,7 +26,7 @@ describe('NotebookResultCount', () => {
fakeUseRootThread = sinon.stub().returns({ children: [] });
$imports.$mock({
'./hooks/use-root-thread': fakeUseRootThread,
'./hooks/use-root-thread': { useRootThread: fakeUseRootThread },
'../helpers/thread': { countVisible: fakeCountVisible },
});
});
......
......@@ -2,9 +2,7 @@ import { mount } from 'enzyme';
import { act } from 'preact/test-utils';
import { checkAccessibility } from '../../../test-util/accessibility';
import { mockImportedComponents } from '../../../test-util/mock-imported-components';
import { ResultSizeError } from '../../search-client';
import NotebookView, { $imports } from '../NotebookView';
......@@ -44,7 +42,7 @@ describe('NotebookView', () => {
$imports.$mock(mockImportedComponents());
$imports.$mock({
'./hooks/use-root-thread': fakeUseRootThread,
'./hooks/use-root-thread': { useRootThread: fakeUseRootThread },
'../store/use-store': { useStoreProxy: () => fakeStore },
'scroll-into-view': fakeScrollIntoView,
});
......
import { mount } from 'enzyme';
import SidebarView from '../SidebarView';
import { $imports } from '../SidebarView';
import { checkAccessibility } from '../../../test-util/accessibility';
import { mockImportedComponents } from '../../../test-util/mock-imported-components';
import SidebarView, { $imports } from '../SidebarView';
describe('SidebarView', () => {
let fakeFrameSync;
......@@ -70,7 +68,7 @@ describe('SidebarView', () => {
$imports.$mock(mockImportedComponents());
$imports.$mock({
'./hooks/use-root-thread': fakeUseRootThread,
'./hooks/use-root-thread': { useRootThread: fakeUseRootThread },
'../store/use-store': { useStoreProxy: () => fakeStore },
'../helpers/tabs': fakeTabsUtil,
});
......
......@@ -40,7 +40,7 @@ describe('StreamView', () => {
$imports.$mock(mockImportedComponents());
$imports.$mock({
'./hooks/use-root-thread': fakeUseRootThread,
'./hooks/use-root-thread': { useRootThread: fakeUseRootThread },
'../store/use-store': { useStoreProxy: () => fakeStore },
'../util/search-filter': fakeSearchFilter,
});
......
......@@ -3,10 +3,9 @@ import { useReducer } from 'preact/hooks';
import { act } from 'preact/test-utils';
import { Injector } from '../../../shared/injector';
import { createSidebarStore } from '../../store';
import { useRootThread } from '../../components/hooks/use-root-thread';
import { ServiceContext } from '../../service-context';
import useRootThread from '../../components/hooks/use-root-thread';
import { createSidebarStore } from '../../store';
const fixtures = {
annotations: [
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment