Commit ebf18e52 authored by Lyza Danger Gardner's avatar Lyza Danger Gardner Committed by Lyza Gardner

Extract helpers from util

Extract modules from the `util` directory that are specific to
the application domain or have application dependencies
parent 02c32fab
......@@ -6,8 +6,8 @@ import { useStoreProxy } from '../store/use-store';
import {
sharingEnabled,
annotationSharingLink,
} from '../util/annotation-sharing';
import { isPrivate, permits } from '../util/permissions';
} from '../helpers/annotation-sharing';
import { isPrivate, permits } from '../helpers/permissions';
import { withServices } from '../util/service-context';
import AnnotationShareControl from './annotation-share-control';
......
......@@ -3,9 +3,9 @@ import { useState } from 'preact/hooks';
import propTypes from 'prop-types';
import { useStoreProxy } from '../store/use-store';
import { isHidden } from '../util/annotation-metadata';
import { isHidden } from '../helpers/annotation-metadata';
import { withServices } from '../util/service-context';
import { applyTheme } from '../util/theme';
import { applyTheme } from '../helpers/theme';
import Button from './button';
import Excerpt from './excerpt';
......
import { createElement } from 'preact';
import propTypes from 'prop-types';
import * as annotationMetadata from '../util/annotation-metadata';
import * as annotationMetadata from '../helpers/annotation-metadata';
/** @typedef {import("../../types/api").Annotation} Annotation */
......
......@@ -4,7 +4,7 @@ import propTypes from 'prop-types';
import { normalizeKeyName } from '../../shared/browser-compatibility-utils';
import { withServices } from '../util/service-context';
import { applyTheme } from '../util/theme';
import { applyTheme } from '../helpers/theme';
import { useStoreProxy } from '../store/use-store';
import AnnotationLicense from './annotation-license';
......
......@@ -7,8 +7,8 @@ import {
isHighlight,
isReply,
hasBeenEdited,
} from '../util/annotation-metadata';
import { isPrivate } from '../util/permissions';
} from '../helpers/annotation-metadata';
import { isPrivate } from '../helpers/permissions';
import AnnotationDocumentInfo from './annotation-document-info';
import AnnotationShareInfo from './annotation-share-info';
......
......@@ -2,10 +2,10 @@ import { createElement } from 'preact';
import propTypes from 'prop-types';
import { useStoreProxy } from '../store/use-store';
import { isNew, isReply } from '../util/annotation-metadata';
import { isShared } from '../util/permissions';
import { isNew, isReply } from '../helpers/annotation-metadata';
import { isShared } from '../helpers/permissions';
import { withServices } from '../util/service-context';
import { applyTheme } from '../util/theme';
import { applyTheme } from '../helpers/theme';
import Button from './button';
import Menu from './menu';
......
......@@ -2,9 +2,9 @@ import classnames from 'classnames';
import { createElement } from 'preact';
import propTypes from 'prop-types';
import { isOrphan, quote } from '../util/annotation-metadata';
import { isOrphan, quote } from '../helpers/annotation-metadata';
import { withServices } from '../util/service-context';
import { applyTheme } from '../util/theme';
import { applyTheme } from '../helpers/theme';
import Excerpt from './excerpt';
......
......@@ -2,9 +2,9 @@ import { createElement } from 'preact';
import { useEffect, useRef, useState } from 'preact/hooks';
import propTypes from 'prop-types';
import { isShareableURI } from '../util/annotation-sharing';
import { isShareableURI } from '../helpers/annotation-sharing';
import { copyText } from '../util/copy-to-clipboard';
import { isPrivate } from '../util/permissions';
import { isPrivate } from '../helpers/permissions';
import { withServices } from '../util/service-context';
import Button from './button';
......
......@@ -2,7 +2,7 @@ import { createElement } from 'preact';
import propTypes from 'prop-types';
import { useStoreProxy } from '../store/use-store';
import { isPrivate } from '../util/permissions';
import { isPrivate } from '../helpers/permissions';
import SvgIcon from '../../shared/components/svg-icon';
......
import { createElement } from 'preact';
import propTypes from 'prop-types';
import { isThirdPartyUser, username } from '../util/account-id';
import { isThirdPartyUser, username } from '../helpers/account-id';
import { withServices } from '../util/service-context';
/**
......
......@@ -3,7 +3,7 @@ import { createElement } from 'preact';
import propTypes from 'prop-types';
import { useStoreProxy } from '../store/use-store';
import { isReply, quote } from '../util/annotation-metadata';
import { isReply, quote } from '../helpers/annotation-metadata';
import { withServices } from '../util/service-context';
import AnnotationActionBar from './annotation-action-bar';
......
......@@ -5,7 +5,7 @@ import propTypes from 'prop-types';
import observeElementSize from '../util/observe-element-size';
import { withServices } from '../util/service-context';
import { applyTheme } from '../util/theme';
import { applyTheme } from '../helpers/theme';
/**
* @typedef InlineControlsProps
......
......@@ -2,7 +2,7 @@ import { createElement } from 'preact';
import { useMemo } from 'preact/hooks';
import propTypes from 'prop-types';
import { countVisible } from '../util/thread';
import { countVisible } from '../helpers/thread';
import Button from './button';
......@@ -10,7 +10,7 @@ import useRootThread from './hooks/use-root-thread';
import { useStoreProxy } from '../store/use-store';
/**
* @typedef {import('../util/build-thread').Thread} Thread
* @typedef {import('../helpers/build-thread').Thread} Thread
*/
/**
......
......@@ -3,7 +3,7 @@ import propTypes from 'prop-types';
import { useStoreProxy } from '../store/use-store';
import { copyText } from '../util/copy-to-clipboard';
import { orgName } from '../util/group-list-item-common';
import { orgName } from '../helpers/group-list-item-common';
import { withServices } from '../util/service-context';
import MenuItem from './menu-item';
......
......@@ -4,10 +4,10 @@ import propTypes from 'prop-types';
import serviceConfig from '../service-config';
import { useStoreProxy } from '../store/use-store';
import { isThirdPartyUser } from '../util/account-id';
import { orgName } from '../util/group-list-item-common';
import groupsByOrganization from '../util/group-organizations';
import isThirdPartyService from '../util/is-third-party-service';
import { isThirdPartyUser } from '../helpers/account-id';
import { orgName } from '../helpers/group-list-item-common';
import groupsByOrganization from '../helpers/group-organizations';
import isThirdPartyService from '../helpers/is-third-party-service';
import { withServices } from '../util/service-context';
import GroupListSection from './group-list-section';
......
......@@ -5,7 +5,7 @@ import propTypes from 'prop-types';
import { useStoreProxy } from '../store/use-store';
import uiConstants from '../ui-constants';
import { withServices } from '../util/service-context';
import VersionData from '../util/version-data';
import VersionData from '../helpers/version-data';
import SidebarPanel from './sidebar-panel';
import SvgIcon from '../../shared/components/svg-icon';
......
......@@ -21,7 +21,7 @@ describe('sidebar/components/hooks/use-root-thread', () => {
$imports.$mock({
'../../store/use-store': { useStoreProxy: () => fakeStore },
'../../util/thread-annotations': fakeThreadAnnotations,
'../../helpers/thread-annotations': fakeThreadAnnotations,
});
// Mount a dummy component to be able to use the `useRootThread` hook
......
import { useMemo } from 'preact/hooks';
import { useStoreProxy } from '../../store/use-store';
import { username } from '../../util/account-id';
import { username } from '../../helpers/account-id';
/** @typedef {import('../../store/modules/filters').FilterOption} FilterOption */
......
import { useMemo } from 'preact/hooks';
import { useStoreProxy } from '../../store/use-store';
import threadAnnotations from '../../util/thread-annotations';
import threadAnnotations from '../../helpers/thread-annotations';
/** @typedef {import('../../util/build-thread').Thread} Thread */
/** @typedef {import('../../helpers/build-thread').Thread} Thread */
/**
* Gather together state relevant to building a root thread of annotations and
......
......@@ -7,9 +7,9 @@ import bridgeEvents from '../../shared/bridge-events';
import serviceConfig from '../service-config';
import { useStoreProxy } from '../store/use-store';
import uiConstants from '../ui-constants';
import { parseAccountID } from '../util/account-id';
import { shouldAutoDisplayTutorial } from '../util/session';
import { applyTheme } from '../util/theme';
import { parseAccountID } from '../helpers/account-id';
import { shouldAutoDisplayTutorial } from '../helpers/session';
import { applyTheme } from '../helpers/theme';
import { withServices } from '../util/service-context';
import AnnotationView from './annotation-view';
......
......@@ -3,7 +3,7 @@ import { createElement } from 'preact';
import propTypes from 'prop-types';
import { useStoreProxy } from '../store/use-store';
import * as annotationMetadata from '../util/annotation-metadata';
import * as annotationMetadata from '../helpers/annotation-metadata';
import { withServices } from '../util/service-context';
/**
......
......@@ -4,7 +4,7 @@ import propTypes from 'prop-types';
import uiConstants from '../ui-constants';
import { useStoreProxy } from '../store/use-store';
import { withServices } from '../util/service-context';
import { applyTheme } from '../util/theme';
import { applyTheme } from '../helpers/theme';
import Button from './button';
......
......@@ -2,7 +2,7 @@ import { createElement } from 'preact';
import useRootThread from './hooks/use-root-thread';
import { useStoreProxy } from '../store/use-store';
import { countVisible } from '../util/thread';
import { countVisible } from '../helpers/thread';
import Spinner from './spinner';
......
......@@ -3,7 +3,7 @@ import propTypes from 'prop-types';
import { useStoreProxy } from '../store/use-store';
import uiConstants from '../ui-constants';
import { pageSharingLink } from '../util/annotation-sharing';
import { pageSharingLink } from '../helpers/annotation-sharing';
import { copyText } from '../util/copy-to-clipboard';
import { withServices } from '../util/service-context';
import { notNull } from '../util/typing';
......
......@@ -5,7 +5,7 @@ import { useEffect, useRef } from 'preact/hooks';
import useRootThread from './hooks/use-root-thread';
import { withServices } from '../util/service-context';
import { useStoreProxy } from '../store/use-store';
import { tabForAnnotation } from '../util/tabs';
import { tabForAnnotation } from '../helpers/tabs';
import FilterStatus from './filter-status';
import LoggedOutMessage from './logged-out-message';
......
......@@ -2,7 +2,7 @@ import { createElement } from 'preact';
import { useMemo } from 'preact/hooks';
import propTypes from 'prop-types';
import { isThirdPartyUser } from '../util/account-id';
import { isThirdPartyUser } from '../helpers/account-id';
import { withServices } from '../util/service-context';
/** @typedef {import('../../types/api').Annotation} Annotation */
......
......@@ -90,11 +90,11 @@ describe('AnnotationActionBar', () => {
$imports.$mock(mockImportedComponents());
$imports.$mock({
'../util/annotation-sharing': {
'../helpers/annotation-sharing': {
sharingEnabled: fakeSharingEnabled,
annotationSharingLink: fakeAnnotationSharingLink,
},
'../util/permissions': { permits: fakePermits },
'../helpers/permissions': { permits: fakePermits },
'../store/use-store': { useStoreProxy: () => fakeStore },
});
sinon.stub(window, 'confirm').returns(false);
......
......@@ -54,7 +54,7 @@ describe('AnnotationBody', () => {
$imports.$mock(mockImportedComponents());
$imports.$mock({
'../util/theme': { applyTheme: fakeApplyTheme },
'../helpers/theme': { applyTheme: fakeApplyTheme },
'../store/use-store': { useStoreProxy: () => fakeStore },
});
});
......
......@@ -27,7 +27,7 @@ describe('AnnotationDocumentInfo', () => {
$imports.$mock(mockImportedComponents());
$imports.$mock({
'../util/annotation-metadata': fakeMetadata,
'../helpers/annotation-metadata': fakeMetadata,
});
});
......
......@@ -55,7 +55,7 @@ describe('AnnotationEditor', () => {
$imports.$mock(mockImportedComponents());
$imports.$mock({
'../store/use-store': { useStoreProxy: () => fakeStore },
'../util/theme': { applyTheme: fakeApplyTheme },
'../helpers/theme': { applyTheme: fakeApplyTheme },
});
});
......
......@@ -41,12 +41,12 @@ describe('AnnotationHeader', () => {
$imports.$mock(mockImportedComponents());
$imports.$mock({
'../store/use-store': { useStoreProxy: () => fakeStore },
'../util/annotation-metadata': {
'../helpers/annotation-metadata': {
isHighlight: fakeIsHighlight,
isReply: fakeIsReply,
hasBeenEdited: fakeHasBeenEdited,
},
'../util/permissions': {
'../helpers/permissions': {
isPrivate: fakeIsPrivate,
},
});
......
......@@ -59,8 +59,8 @@ describe('AnnotationPublishControl', () => {
$imports.$mock(mockImportedComponents());
$imports.$mock({
'../store/use-store': { useStoreProxy: () => fakeStore },
'../util/annotation-metadata': fakeMetadata,
'../util/theme': {
'../helpers/annotation-metadata': fakeMetadata,
'../helpers/theme': {
applyTheme: fakeApplyTheme,
},
});
......
......@@ -33,7 +33,7 @@ describe('AnnotationQuote', () => {
$imports.$mock(mockImportedComponents());
$imports.$mock({
'../util/annotation-metadata': {
'../helpers/annotation-metadata': {
quote: fakeQuote,
isOrphan: fakeIsOrphan,
},
......
......@@ -89,9 +89,9 @@ describe('AnnotationShareControl', () => {
$imports.$mock(mockImportedComponents());
$imports.$mock({
'../util/annotation-sharing': { isShareableURI: fakeIsShareableURI },
'../helpers/annotation-sharing': { isShareableURI: fakeIsShareableURI },
'../util/copy-to-clipboard': fakeCopyToClipboard,
'../util/permissions': { isPrivate: fakeIsPrivate },
'../helpers/permissions': { isPrivate: fakeIsPrivate },
'./hooks/use-element-should-close': sinon.stub(),
'../../shared/user-agent': { isIOS: fakeIsIOS },
});
......
......@@ -38,7 +38,7 @@ describe('AnnotationShareInfo', () => {
$imports.$mock(mockImportedComponents());
$imports.$mock({
'../store/use-store': { useStoreProxy: () => fakeStore },
'../util/permissions': { isPrivate: fakeIsPrivate },
'../helpers/permissions': { isPrivate: fakeIsPrivate },
});
});
......
......@@ -61,7 +61,7 @@ describe('Annotation', () => {
$imports.$mock(mockImportedComponents());
$imports.$mock({
'../util/annotation-metadata': fakeMetadata,
'../helpers/annotation-metadata': fakeMetadata,
'../store/use-store': { useStoreProxy: () => fakeStore },
});
});
......
......@@ -38,7 +38,7 @@ describe('AnnotationUser', () => {
$imports.$mock(mockImportedComponents());
$imports.$mock({
'../util/account-id': {
'../helpers/account-id': {
isThirdPartyUser: fakeIsThirdPartyUser,
username: fakeUsername,
},
......
......@@ -55,7 +55,7 @@ describe('FilterStatus', () => {
$imports.$mock({
'./hooks/use-root-thread': fakeUseRootThread,
'../store/use-store': { useStoreProxy: () => fakeStore },
'../util/thread': fakeThreadUtil,
'../helpers/thread': fakeThreadUtil,
});
});
......
......@@ -71,7 +71,7 @@ describe('GroupListItem', () => {
'../util/copy-to-clipboard': {
copyText: fakeCopyText,
},
'../util/group-list-item-common': fakeGroupListItemCommon,
'../helpers/group-list-item-common': fakeGroupListItemCommon,
'../store/use-store': { useStoreProxy: () => fakeStore },
});
......
......@@ -119,7 +119,7 @@ describe('GroupList', () => {
const fakeGroupOrganizations = groups =>
groups.sort((a, b) => a.id.localeCompare(b.id));
$imports.$mock({
'../util/group-organizations': fakeGroupOrganizations,
'../helpers/group-organizations': fakeGroupOrganizations,
});
const wrapper = createGroupList();
......@@ -171,7 +171,7 @@ describe('GroupList', () => {
context('when `isThirdPartyService` is true', () => {
beforeEach(() => {
$imports.$mock({
'../util/is-third-party-service': () => true,
'../helpers/is-third-party-service': () => true,
});
});
......
......@@ -38,7 +38,7 @@ describe('HelpPanel', function () {
$imports.$mock(mockImportedComponents());
$imports.$mock({
'../store/use-store': { useStoreProxy: () => fakeStore },
'../util/version-data': fakeVersionData,
'../helpers/version-data': fakeVersionData,
});
});
......
......@@ -82,10 +82,10 @@ describe('HypothesisApp', () => {
$imports.$mock({
'../service-config': fakeServiceConfig,
'../store/use-store': { useStoreProxy: () => fakeStore },
'../util/session': {
'../helpers/session': {
shouldAutoDisplayTutorial: fakeShouldAutoDisplayTutorial,
},
'../util/theme': { applyTheme: fakeApplyTheme },
'../helpers/theme': { applyTheme: fakeApplyTheme },
});
});
......
......@@ -31,7 +31,7 @@ describe('NotebookResultCount', () => {
$imports.$mock({
'./hooks/use-root-thread': fakeUseRootThread,
'../store/use-store': { useStoreProxy: () => fakeStore },
'../util/thread': { countVisible: fakeCountVisible },
'../helpers/thread': { countVisible: fakeCountVisible },
});
});
......
......@@ -58,7 +58,7 @@ describe('ShareAnnotationsPanel', () => {
$imports.$mock(mockImportedComponents());
$imports.$mock({
'../store/use-store': { useStoreProxy: () => fakeStore },
'../util/annotation-sharing': {
'../helpers/annotation-sharing': {
pageSharingLink: fakePageSharingLink,
},
'../util/copy-to-clipboard': fakeCopyToClipboard,
......
......@@ -68,7 +68,7 @@ describe('SidebarView', () => {
$imports.$mock({
'./hooks/use-root-thread': fakeUseRootThread,
'../store/use-store': { useStoreProxy: () => fakeStore },
'../util/tabs': fakeTabsUtil,
'../helpers/tabs': fakeTabsUtil,
});
});
......
......@@ -32,7 +32,7 @@ describe('TagList', function () {
$imports.$mock(mockImportedComponents());
$imports.$mock({
'../util/account-id': {
'../helpers/account-id': {
isThirdPartyUser: fakeIsThirdPartyUser,
},
});
......
......@@ -69,9 +69,9 @@ describe('ThreadList', () => {
$imports.$mock(mockImportedComponents());
$imports.$mock({
'../store/use-store': { useStoreProxy: () => fakeStore },
'../util/annotation-metadata': fakeMetadata,
'../helpers/annotation-metadata': fakeMetadata,
'../util/dom': fakeDomUtil,
'../util/visible-threads': fakeVisibleThreadsUtil,
'../helpers/visible-threads': fakeVisibleThreadsUtil,
});
});
......@@ -231,7 +231,7 @@ describe('ThreadList', () => {
// For these tests, don't mock element height or visible thread calculation.
$imports.$restore({
'../util/dom': true,
'../util/visible-threads': true,
'../helpers/visible-threads': true,
});
});
......@@ -240,7 +240,7 @@ describe('ThreadList', () => {
const renderedThreads = wrapper.find('ThreadCard');
// "7" is the current expected value given the thread heights, scroll
// container size and constants in `../util/visible-threads`.
// container size and constants in `../helpers/visible-threads`.
assert.equal(renderedThreads.length, 7);
});
......
......@@ -31,7 +31,7 @@ const addChildThread = parent => {
return childThread;
};
// NB: This logic lifted from `util/build-thread.js`
// NB: This logic lifted from `helpers/build-thread.js`
function countRepliesAndDepth(thread, depth) {
const children = thread.children.map(child => {
return countRepliesAndDepth(child, depth + 1);
......@@ -96,7 +96,7 @@ describe('Thread', () => {
$imports.$mock(mockImportedComponents());
$imports.$mock({
'../store/use-store': { useStoreProxy: () => fakeStore },
'../util/thread': fakeThreadUtil,
'../helpers/thread': fakeThreadUtil,
});
});
......
......@@ -41,7 +41,7 @@ describe('TopBar', () => {
$imports.$mock(mockImportedComponents());
$imports.$mock({
'../store/use-store': { useStoreProxy: () => fakeStore },
'../util/is-third-party-service': fakeIsThirdPartyService,
'../helpers/is-third-party-service': fakeIsThirdPartyService,
'../service-config': fakeServiceConfig,
});
});
......
......@@ -19,7 +19,7 @@ describe('Tutorial', function () {
$imports.$mock(mockImportedComponents());
$imports.$mock({
'../util/is-third-party-service': fakeIsThirdPartyService,
'../helpers/is-third-party-service': fakeIsThirdPartyService,
});
});
......
......@@ -57,7 +57,7 @@ describe('UserMenu', () => {
$imports.$mock(mockImportedComponents());
$imports.$mock({
'../util/account-id': {
'../helpers/account-id': {
isThirdPartyUser: fakeIsThirdPartyUser,
},
'../service-config': fakeServiceConfig,
......
......@@ -4,16 +4,16 @@ import propTypes from 'prop-types';
import debounce from 'lodash.debounce';
import { useStoreProxy } from '../store/use-store';
import { isHighlight } from '../util/annotation-metadata';
import { isHighlight } from '../helpers/annotation-metadata';
import { getElementHeightWithMargins } from '../util/dom';
import {
calculateVisibleThreads,
THREAD_DIMENSION_DEFAULTS,
} from '../util/visible-threads';
} from '../helpers/visible-threads';
import ThreadCard from './thread-card';
/** @typedef {import('../util/build-thread').Thread} Thread */
/** @typedef {import('../helpers/build-thread').Thread} Thread */
// The precision of the `scrollPosition` value in pixels; values will be rounded
// down to the nearest multiple of this scale value
......
......@@ -5,13 +5,13 @@ import { useMemo } from 'preact/hooks';
import propTypes from 'prop-types';
import { useStoreProxy } from '../store/use-store';
import { withServices } from '../util/service-context';
import { countHidden, countVisible } from '../util/thread';
import { countHidden, countVisible } from '../helpers/thread';
import Annotation from './annotation';
import Button from './button';
import ModerationBanner from './moderation-banner';
/** @typedef {import('../util/build-thread').Thread} Thread */
/** @typedef {import('../helpers/build-thread').Thread} Thread */
/**
* @typedef ThreadProps
......
......@@ -5,9 +5,9 @@ import bridgeEvents from '../../shared/bridge-events';
import serviceConfig from '../service-config';
import { useStoreProxy } from '../store/use-store';
import uiConstants from '../ui-constants';
import isThirdPartyService from '../util/is-third-party-service';
import isThirdPartyService from '../helpers/is-third-party-service';
import { withServices } from '../util/service-context';
import { applyTheme } from '../util/theme';
import { applyTheme } from '../helpers/theme';
import Button from './button';
import GroupList from './group-list';
......
import { createElement } from 'preact';
import propTypes from 'prop-types';
import isThirdPartyService from '../util/is-third-party-service';
import isThirdPartyService from '../helpers/is-third-party-service';
import { withServices } from '../util/service-context';
import SvgIcon from '../../shared/components/svg-icon';
......
......@@ -3,7 +3,7 @@ import propTypes from 'prop-types';
import bridgeEvents from '../../shared/bridge-events';
import serviceConfig from '../service-config';
import { isThirdPartyUser } from '../util/account-id';
import { isThirdPartyUser } from '../helpers/account-id';
import { useStoreProxy } from '../store/use-store';
import { withServices } from '../util/service-context';
......
......@@ -8,7 +8,7 @@ import Button from './button';
/**
* @typedef VersionInfoProps
* @prop {import('../util/version-data').default} versionData - Object with version information
* @prop {import('../helpers/version-data').default} versionData - Object with version information
* @prop {Object} toastMessenger - Injected service
*/
......
import immutable from './immutable';
import immutable from '../util/immutable';
/**
* @typedef {import('../../types/api').Group} Group
......
// Functions that determine which tab an annotation should be displayed in.
import * as metadata from './annotation-metadata';
import * as metadata from '../helpers/annotation-metadata';
/**
* @typedef {import('../../types/api').Annotation} Annotation
......
import { parseAccountID, username, isThirdPartyUser } from '../account-id';
describe('sidebar.util.account-id', function () {
describe('sidebar/helpers/account-id', function () {
const term = 'acct:hacker@example.com';
describe('parseAccountID', function () {
......
......@@ -4,7 +4,7 @@ import * as annotationMetadata from '../annotation-metadata';
const documentMetadata = annotationMetadata.documentMetadata;
const domainAndTitle = annotationMetadata.domainAndTitle;
describe('sidebar/util/annotation-metadata', () => {
describe('sidebar/helpers/annotation-metadata', () => {
const fakeAnnotation = (props = {}) => {
return {
document: {},
......
import * as sharingUtil from '../annotation-sharing';
describe('sidebar.util.annotation-sharing', () => {
describe('sidebar/helpers/annotation-sharing', () => {
let fakeAnnotation;
let fakeServiceConfig;
let fakeServiceSettings;
......
import buildThread from '../build-thread';
import * as metadata from '../annotation-metadata';
import * as metadata from '../../helpers/annotation-metadata';
// Fixture with two top level annotations, one note and one reply
const SIMPLE_FIXTURE = [
......@@ -69,9 +69,9 @@ function createThread(fixture, options, keys) {
return rootThread.children;
}
describe('sidebar/util/build-thread', () => {
describe('threading', () => {
it('arranges parents and children as a thread', () => {
describe('sidebar/helpers/build-thread', function () {
describe('threading', function () {
it('arranges parents and children as a thread', function () {
const thread = createThread(SIMPLE_FIXTURE);
assert.deepEqual(thread, [
{
......
import * as groupListItemCommon from '../group-list-item-common';
describe('sidebar/util/groupListItemCommon', () => {
describe('sidebar/helpers/group-list-item-common', () => {
describe('orgName', () => {
it('returns the organization name if it exists', () => {
const fakeGroup = { id: 'groupid', organization: { name: 'org' } };
......
import * as orgFixtures from '../../test/group-fixtures';
import groupsByOrganization from '../group-organizations';
describe('group-organizations', function () {
describe('sidebar/helpers/group-organizations', function () {
context('when sorting organizations and their contained groups', function () {
it('should put the default organization groups last', function () {
const defaultOrg = orgFixtures.defaultOrganization();
......
import { combineGroups, $imports } from '../groups';
describe('sidebar.util.groups', () => {
describe('sidebar/helpers/groups', () => {
let fakeServiceConfig;
describe('combineGroups', () => {
beforeEach(() => {
......
import isThirdPartyService from '../is-third-party-service';
import { $imports } from '../is-third-party-service';
describe('sidebar.util.isThirdPartyService', () => {
describe('sidebar/helpers/is-third-party-service', () => {
let fakeServiceConfig;
let fakeSettings;
......
......@@ -2,7 +2,7 @@ import * as permissions from '../permissions';
const userid = 'acct:flash@gord.on';
describe('sidebar/util/permissions', () => {
describe('sidebar/helpers/permissions', () => {
describe('#privatePermissions', () => {
it('only allows the user to read the annotation', () => {
assert.deepEqual(permissions.privatePermissions(userid), {
......
import * as sessionUtil from '../session';
describe('sidebar/util/session', () => {
describe('sidebar/helpers/session', () => {
describe('#shouldShowSidebarTutorial', () => {
it('shows sidebar tutorial if the settings object has the show_sidebar_tutorial key set', function () {
const sessionState = {
......
......@@ -2,7 +2,7 @@ import * as fixtures from '../../test/annotation-fixtures';
import uiConstants from '../../ui-constants';
import * as tabs from '../tabs';
describe('tabs', function () {
describe('sidebar/helpers/tabs', function () {
describe('tabForAnnotation', function () {
[
{
......
import { applyTheme } from '../theme';
describe('sidebar/util/theme/applyTheme', () => {
describe('sidebar/helpers/theme', () => {
let fakeSettings;
beforeEach(() => {
......
......@@ -3,7 +3,7 @@ import uiConstants from '../../ui-constants';
import threadAnnotations from '../thread-annotations';
import { sorters } from '../thread-sorters';
import { $imports } from '../thread-annotations';
import immutable from '../immutable';
import immutable from '../../util/immutable';
const fixtures = immutable({
emptyThread: {
......@@ -17,7 +17,7 @@ const fixtures = immutable({
},
});
describe('sidebar/utils/thread-annotations', () => {
describe('sidebar/helpers/thread-annotations', () => {
let fakeBuildThread;
let fakeFilterAnnotations;
let fakeSearchFilter;
......@@ -46,7 +46,7 @@ describe('sidebar/utils/thread-annotations', () => {
$imports.$mock({
'./build-thread': fakeBuildThread,
'./search-filter': fakeSearchFilter,
'../util/search-filter': fakeSearchFilter,
'./view-filter': fakeFilterAnnotations,
});
});
......
import * as threadUtil from '../thread';
describe('sidebar/util/thread', () => {
describe('sidebar/helpers/thread', () => {
const fakeThread = () => {
return {
annotation: {},
......
import VersionData from '../version-data';
describe('VersionData', () => {
describe('sidebar/helpers/version-data', () => {
let clock;
beforeEach(() => {
......
......@@ -17,7 +17,7 @@ const poem = {
Only this and nothing more.”`,
};
describe('sidebar/util/view-filter', () => {
describe('sidebar/helpers/view-filter', () => {
let fakeUnicode;
beforeEach(() => {
......@@ -27,7 +27,7 @@ describe('sidebar/util/view-filter', () => {
};
$imports.$mock({
'./unicode': fakeUnicode,
'../util/unicode': fakeUnicode,
});
});
......
import { calculateVisibleThreads } from '../visible-threads';
describe('sidebar/util/visible-threads', () => {
describe('sidebar/helpers/visible-threads', () => {
let fakeThreads;
let fakeThreadHeights;
let fakeWindowHeight;
......
import buildThread from './build-thread';
import memoize from './memoize';
import { generateFacetedFilter } from './search-filter';
import memoize from '../util/memoize';
import { generateFacetedFilter } from '../util/search-filter';
import filterAnnotations from './view-filter';
import { shouldShowInTab } from './tabs';
import { sorters } from './thread-sorters';
......
import { notNull } from './typing';
import { notNull } from '../util/typing';
/** @typedef {import('../../types/api').Annotation} Annotation */
/** @typedef {import('../util/build-thread').Thread} Thread */
/** @typedef {import('./build-thread').Thread} Thread */
/**
* Count the number of annotations/replies in the `thread` whose `visible`
......
......@@ -12,7 +12,7 @@
*/
import { quote } from './annotation-metadata';
import * as unicodeUtils from './unicode';
import * as unicodeUtils from '../util/unicode';
/**
* @typedef Filter
......
/**
* @typedef {import('../util/build-thread').Thread} Thread
* @typedef {import('../helpers/build-thread').Thread} Thread
*/
export const THREAD_DIMENSION_DEFAULTS = {
......
......@@ -6,12 +6,12 @@
* application-store representations. Interacts with API services as needed.
*/
import * as metadata from '../util/annotation-metadata';
import * as metadata from '../helpers/annotation-metadata';
import {
defaultPermissions,
privatePermissions,
sharedPermissions,
} from '../util/permissions';
} from '../helpers/permissions';
import { generateHexString } from '../util/random';
import uiConstants from '../ui-constants';
......
......@@ -3,7 +3,7 @@ import debounce from 'lodash.debounce';
import bridgeEvents from '../../shared/bridge-events';
import Discovery from '../../shared/discovery';
import uiConstants from '../ui-constants';
import * as metadata from '../util/annotation-metadata';
import * as metadata from '../helpers/annotation-metadata';
import { watch } from '../util/watch';
/**
......
import serviceConfig from '../service-config';
import { isReply } from '../util/annotation-metadata';
import { combineGroups } from '../util/groups';
import { isReply } from '../helpers/annotation-metadata';
import { combineGroups } from '../helpers/groups';
import { awaitStateChange } from '../util/state';
import { watch } from '../util/watch';
......
......@@ -12,7 +12,7 @@
import SearchClient from '../search-client';
import { isReply } from '../util/annotation-metadata';
import { isReply } from '../helpers/annotation-metadata';
// @inject
export default function loadAnnotationsService(
......
......@@ -54,8 +54,8 @@ describe('annotationsService', () => {
};
$imports.$mock({
'../util/annotation-metadata': fakeMetadata,
'../util/permissions': {
'../helpers/annotation-metadata': fakeMetadata,
'../helpers/permissions': {
defaultPermissions: fakeDefaultPermissions,
privatePermissions: fakePrivatePermissions,
sharedPermissions: fakeSharedPermissions,
......
......@@ -124,7 +124,7 @@ describe('groups', function () {
fakeSettings = { group: null };
$imports.$mock({
'../util/annotation-metadata': fakeMetadata,
'../helpers/annotation-metadata': fakeMetadata,
});
});
......
/**
* @typedef {import('../util/build-thread').Thread} Thread
* @typedef {import('../helpers/build-thread').Thread} Thread
*/
// @inject
......
......@@ -14,7 +14,7 @@
import { createSelector } from 'reselect';
import * as metadata from '../../util/annotation-metadata';
import * as metadata from '../../helpers/annotation-metadata';
import { countIf, toTrueMap, trueKeys } from '../../util/collections';
import * as util from '../util';
import { storeModule } from '../create-store';
......
import { createSelector } from 'reselect';
import * as metadata from '../../util/annotation-metadata';
import * as metadata from '../../helpers/annotation-metadata';
import * as util from '../util';
import { storeModule } from '../create-store';
......
......@@ -19,7 +19,7 @@
import { createSelector } from 'reselect';
import uiConstants from '../../ui-constants';
import * as metadata from '../../util/annotation-metadata';
import * as metadata from '../../helpers/annotation-metadata';
import { countIf, trueKeys, toTrueMap } from '../../util/collections';
import * as util from '../util';
import { storeModule } from '../create-store';
......
import * as fixtures from '../../../test/annotation-fixtures';
import * as metadata from '../../../util/annotation-metadata';
import * as metadata from '../../../helpers/annotation-metadata';
import createStore from '../../create-store';
import annotations from '../annotations';
import route from '../route';
......
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