Unverified Commit 0d93b3a0 authored by Robert Knight's avatar Robert Knight Committed by GitHub

Merge pull request #1655 from hypothesis/change-dollar-imports

Modify a mocking idiom that doesn't work with ES modules
parents 7ae48f7e 426d2670
const configFrom = require('../index'); const configFrom = require('../index');
const { $imports } = require('../index');
describe('annotator.config.index', function() { describe('annotator.config.index', function() {
let fakeSettingsFrom; let fakeSettingsFrom;
...@@ -8,13 +9,13 @@ describe('annotator.config.index', function() { ...@@ -8,13 +9,13 @@ describe('annotator.config.index', function() {
hostPageSetting: sinon.stub(), hostPageSetting: sinon.stub(),
}); });
configFrom.$imports.$mock({ $imports.$mock({
'./settings': fakeSettingsFrom, './settings': fakeSettingsFrom,
}); });
}); });
afterEach(() => { afterEach(() => {
configFrom.$imports.$restore(); $imports.$restore();
}); });
it('gets the configuration settings', function() { it('gets the configuration settings', function() {
......
const settingsFrom = require('../settings'); const settingsFrom = require('../settings');
const { $imports } = require('../settings');
describe('annotator.config.settingsFrom', function() { describe('annotator.config.settingsFrom', function() {
let fakeConfigFuncSettingsFrom; let fakeConfigFuncSettingsFrom;
...@@ -12,7 +13,7 @@ describe('annotator.config.settingsFrom', function() { ...@@ -12,7 +13,7 @@ describe('annotator.config.settingsFrom', function() {
jsonConfigsFrom: sinon.stub().returns({}), jsonConfigsFrom: sinon.stub().returns({}),
}; };
settingsFrom.$imports.$mock({ $imports.$mock({
'./config-func-settings-from': fakeConfigFuncSettingsFrom, './config-func-settings-from': fakeConfigFuncSettingsFrom,
'./is-browser-extension': fakeIsBrowserExtension, './is-browser-extension': fakeIsBrowserExtension,
'../../shared/settings': fakeSharedSettings, '../../shared/settings': fakeSharedSettings,
...@@ -20,7 +21,7 @@ describe('annotator.config.settingsFrom', function() { ...@@ -20,7 +21,7 @@ describe('annotator.config.settingsFrom', function() {
}); });
afterEach(() => { afterEach(() => {
settingsFrom.$imports.$restore(); $imports.$restore();
}); });
describe('#sidebarAppUrl', function() { describe('#sidebarAppUrl', function() {
......
Plugin = require('../../plugin') Plugin = require('../../plugin')
CrossFrame = require('../cross-frame') CrossFrame = require('../cross-frame')
{ $imports } = require('../cross-frame')
describe 'CrossFrame', -> describe 'CrossFrame', ->
fakeDiscovery = null fakeDiscovery = null
...@@ -39,7 +40,7 @@ describe 'CrossFrame', -> ...@@ -39,7 +40,7 @@ describe 'CrossFrame', ->
proxyDiscovery = sandbox.stub().returns(fakeDiscovery) proxyDiscovery = sandbox.stub().returns(fakeDiscovery)
proxyBridge = sandbox.stub().returns(fakeBridge) proxyBridge = sandbox.stub().returns(fakeBridge)
CrossFrame.$imports.$mock({ $imports.$mock({
'../plugin': Plugin, '../plugin': Plugin,
'../annotation-sync': proxyAnnotationSync, '../annotation-sync': proxyAnnotationSync,
'../../shared/bridge': proxyBridge, '../../shared/bridge': proxyBridge,
...@@ -48,7 +49,7 @@ describe 'CrossFrame', -> ...@@ -48,7 +49,7 @@ describe 'CrossFrame', ->
afterEach -> afterEach ->
sandbox.restore() sandbox.restore()
CrossFrame.$imports.$restore() $imports.$restore()
describe 'CrossFrame constructor', -> describe 'CrossFrame constructor', ->
it 'instantiates the Discovery component', -> it 'instantiates the Discovery component', ->
......
const events = require('../../shared/bridge-events'); const events = require('../../shared/bridge-events');
const features = require('../features'); const features = require('../features');
const { $imports } = require('../features');
describe('features - annotation layer', function() { describe('features - annotation layer', function() {
let featureFlagsUpdateHandler; let featureFlagsUpdateHandler;
...@@ -16,7 +17,7 @@ describe('features - annotation layer', function() { ...@@ -16,7 +17,7 @@ describe('features - annotation layer', function() {
beforeEach(function() { beforeEach(function() {
fakeWarnOnce = sinon.stub(); fakeWarnOnce = sinon.stub();
features.$imports.$mock({ $imports.$mock({
'../shared/warn-once': fakeWarnOnce, '../shared/warn-once': fakeWarnOnce,
}); });
...@@ -34,7 +35,7 @@ describe('features - annotation layer', function() { ...@@ -34,7 +35,7 @@ describe('features - annotation layer', function() {
afterEach(function() { afterEach(function() {
features.reset(); features.reset();
features.$imports.$restore(); $imports.$restore();
}); });
describe('flagEnabled', function() { describe('flagEnabled', function() {
......
...@@ -7,6 +7,7 @@ $ = require('jquery') ...@@ -7,6 +7,7 @@ $ = require('jquery')
Delegator['@noCallThru'] = true Delegator['@noCallThru'] = true
Guest = require('../guest') Guest = require('../guest')
{ $imports } = require('../guest')
rangeUtil = null rangeUtil = null
selections = null selections = null
...@@ -74,7 +75,7 @@ describe 'Guest', -> ...@@ -74,7 +75,7 @@ describe 'Guest', ->
anchor: sinon.stub() anchor: sinon.stub()
} }
Guest.$imports.$mock({ $imports.$mock({
'./adder': {Adder: FakeAdder}, './adder': {Adder: FakeAdder},
'./anchoring/html': htmlAnchoring, './anchoring/html': htmlAnchoring,
'./highlighter': highlighter, './highlighter': highlighter,
...@@ -103,7 +104,7 @@ describe 'Guest', -> ...@@ -103,7 +104,7 @@ describe 'Guest', ->
afterEach -> afterEach ->
sandbox.restore() sandbox.restore()
console.warn.restore() console.warn.restore()
Guest.$imports.$restore() $imports.$restore()
describe 'plugins', -> describe 'plugins', ->
fakePlugin = null fakePlugin = null
......
...@@ -2,6 +2,7 @@ const isLoaded = require('../../util/frame-util').isLoaded; ...@@ -2,6 +2,7 @@ const isLoaded = require('../../util/frame-util').isLoaded;
const FRAME_DEBOUNCE_WAIT = require('../../frame-observer').DEBOUNCE_WAIT + 10; const FRAME_DEBOUNCE_WAIT = require('../../frame-observer').DEBOUNCE_WAIT + 10;
const CrossFrame = require('../../plugin/cross-frame'); const CrossFrame = require('../../plugin/cross-frame');
const { $imports } = require('../../plugin/cross-frame');
describe('CrossFrame multi-frame scenario', function() { describe('CrossFrame multi-frame scenario', function() {
let fakeAnnotationSync; let fakeAnnotationSync;
...@@ -28,7 +29,7 @@ describe('CrossFrame multi-frame scenario', function() { ...@@ -28,7 +29,7 @@ describe('CrossFrame multi-frame scenario', function() {
proxyAnnotationSync = sandbox.stub().returns(fakeAnnotationSync); proxyAnnotationSync = sandbox.stub().returns(fakeAnnotationSync);
proxyBridge = sandbox.stub().returns(fakeBridge); proxyBridge = sandbox.stub().returns(fakeBridge);
CrossFrame.$imports.$mock({ $imports.$mock({
'../annotation-sync': proxyAnnotationSync, '../annotation-sync': proxyAnnotationSync,
'../../shared/bridge': proxyBridge, '../../shared/bridge': proxyBridge,
}); });
...@@ -52,7 +53,7 @@ describe('CrossFrame multi-frame scenario', function() { ...@@ -52,7 +53,7 @@ describe('CrossFrame multi-frame scenario', function() {
crossFrame.destroy(); crossFrame.destroy();
container.parentNode.removeChild(container); container.parentNode.removeChild(container);
CrossFrame.$imports.$restore(); $imports.$restore();
}); });
it('detects frames on page', function() { it('detects frames on page', function() {
......
events = require('../../shared/bridge-events') events = require('../../shared/bridge-events')
Sidebar = require('../sidebar') Sidebar = require('../sidebar')
{ $imports } = require('../sidebar')
DEFAULT_WIDTH = 350 DEFAULT_WIDTH = 350
DEFAULT_HEIGHT = 600 DEFAULT_HEIGHT = 600
...@@ -15,10 +16,10 @@ describe 'Sidebar', -> ...@@ -15,10 +16,10 @@ describe 'Sidebar', ->
before -> before ->
rafStub = (fn) -> rafStub = (fn) ->
fn() fn()
Sidebar.$imports.$mock({ raf: rafStub }) $imports.$mock({ raf: rafStub })
after -> after ->
Sidebar.$imports.$restore() $imports.$restore()
createSidebar = (config={}) -> createSidebar = (config={}) ->
config = Object.assign({}, sidebarConfig, config) config = Object.assign({}, sidebarConfig, config)
......
const boot = require('../boot'); const boot = require('../boot');
const { $imports } = require('../boot');
function assetUrl(url) { function assetUrl(url) {
return `https://marginal.ly/client/build/${url}`; return `https://marginal.ly/client/build/${url}`;
...@@ -16,13 +17,13 @@ describe('bootstrap', function() { ...@@ -16,13 +17,13 @@ describe('bootstrap', function() {
requiredPolyfillSets: sinon.stub().returns([]), requiredPolyfillSets: sinon.stub().returns([]),
}; };
boot.$imports.$mock({ $imports.$mock({
'../shared/polyfills': fakePolyfills, '../shared/polyfills': fakePolyfills,
}); });
}); });
afterEach(function() { afterEach(function() {
boot.$imports.$restore(); $imports.$restore();
iframe.remove(); iframe.remove();
}); });
......
...@@ -5,6 +5,7 @@ const { act } = require('preact/test-utils'); ...@@ -5,6 +5,7 @@ const { act } = require('preact/test-utils');
const { waitFor } = require('./util'); const { waitFor } = require('./util');
const AnnotationActionBar = require('../annotation-action-bar'); const AnnotationActionBar = require('../annotation-action-bar');
const { $imports } = require('../annotation-action-bar');
const mockImportedComponents = require('./mock-imported-components'); const mockImportedComponents = require('./mock-imported-components');
describe('AnnotationActionBar', () => { describe('AnnotationActionBar', () => {
...@@ -92,8 +93,8 @@ describe('AnnotationActionBar', () => { ...@@ -92,8 +93,8 @@ describe('AnnotationActionBar', () => {
updateFlagStatus: sinon.stub(), updateFlagStatus: sinon.stub(),
}; };
AnnotationActionBar.$imports.$mock(mockImportedComponents()); $imports.$mock(mockImportedComponents());
AnnotationActionBar.$imports.$mock({ $imports.$mock({
'../util/annotation-sharing': { '../util/annotation-sharing': {
isShareable: fakeIsShareable, isShareable: fakeIsShareable,
shareURI: sinon.stub().returns('http://share.me'), shareURI: sinon.stub().returns('http://share.me'),
...@@ -105,7 +106,7 @@ describe('AnnotationActionBar', () => { ...@@ -105,7 +106,7 @@ describe('AnnotationActionBar', () => {
afterEach(() => { afterEach(() => {
window.confirm.restore(); window.confirm.restore();
AnnotationActionBar.$imports.$restore(); $imports.$restore();
}); });
describe('edit action button', () => { describe('edit action button', () => {
......
...@@ -2,6 +2,7 @@ const { createElement } = require('preact'); ...@@ -2,6 +2,7 @@ const { createElement } = require('preact');
const { mount } = require('enzyme'); const { mount } = require('enzyme');
const AnnotationBody = require('../annotation-body'); const AnnotationBody = require('../annotation-body');
const { $imports } = require('../annotation-body');
const mockImportedComponents = require('./mock-imported-components'); const mockImportedComponents = require('./mock-imported-components');
describe('AnnotationBody', () => { describe('AnnotationBody', () => {
...@@ -10,11 +11,11 @@ describe('AnnotationBody', () => { ...@@ -10,11 +11,11 @@ describe('AnnotationBody', () => {
} }
beforeEach(() => { beforeEach(() => {
AnnotationBody.$imports.$mock(mockImportedComponents()); $imports.$mock(mockImportedComponents());
}); });
afterEach(() => { afterEach(() => {
AnnotationBody.$imports.$restore(); $imports.$restore();
}); });
it('displays the body if `isEditing` is false', () => { it('displays the body if `isEditing` is false', () => {
......
...@@ -4,6 +4,7 @@ const { mount } = require('enzyme'); ...@@ -4,6 +4,7 @@ const { mount } = require('enzyme');
const fixtures = require('../../test/annotation-fixtures'); const fixtures = require('../../test/annotation-fixtures');
const AnnotationDocumentInfo = require('../annotation-document-info'); const AnnotationDocumentInfo = require('../annotation-document-info');
const { $imports } = require('../annotation-document-info');
const mockImportedComponents = require('./mock-imported-components'); const mockImportedComponents = require('./mock-imported-components');
describe('AnnotationDocumentInfo', () => { describe('AnnotationDocumentInfo', () => {
...@@ -23,14 +24,14 @@ describe('AnnotationDocumentInfo', () => { ...@@ -23,14 +24,14 @@ describe('AnnotationDocumentInfo', () => {
fakeDomainAndTitle = sinon.stub(); fakeDomainAndTitle = sinon.stub();
fakeMetadata = { domainAndTitle: fakeDomainAndTitle }; fakeMetadata = { domainAndTitle: fakeDomainAndTitle };
AnnotationDocumentInfo.$imports.$mock(mockImportedComponents()); $imports.$mock(mockImportedComponents());
AnnotationDocumentInfo.$imports.$mock({ $imports.$mock({
'../util/annotation-metadata': fakeMetadata, '../util/annotation-metadata': fakeMetadata,
}); });
}); });
afterEach(() => { afterEach(() => {
AnnotationDocumentInfo.$imports.$restore(); $imports.$restore();
}); });
it('should not render if there is no document title', () => { it('should not render if there is no document title', () => {
......
...@@ -4,6 +4,7 @@ const { mount } = require('enzyme'); ...@@ -4,6 +4,7 @@ const { mount } = require('enzyme');
const fixtures = require('../../test/annotation-fixtures'); const fixtures = require('../../test/annotation-fixtures');
const AnnotationHeader = require('../annotation-header'); const AnnotationHeader = require('../annotation-header');
const { $imports } = require('../annotation-header');
const mockImportedComponents = require('./mock-imported-components'); const mockImportedComponents = require('./mock-imported-components');
describe('AnnotationHeader', () => { describe('AnnotationHeader', () => {
...@@ -22,11 +23,11 @@ describe('AnnotationHeader', () => { ...@@ -22,11 +23,11 @@ describe('AnnotationHeader', () => {
}; };
beforeEach(() => { beforeEach(() => {
AnnotationHeader.$imports.$mock(mockImportedComponents()); $imports.$mock(mockImportedComponents());
}); });
afterEach(() => { afterEach(() => {
AnnotationHeader.$imports.$restore(); $imports.$restore();
}); });
describe('collapsed replies', () => { describe('collapsed replies', () => {
......
...@@ -2,6 +2,7 @@ const { createElement } = require('preact'); ...@@ -2,6 +2,7 @@ const { createElement } = require('preact');
const { mount } = require('enzyme'); const { mount } = require('enzyme');
const AnnotationPublishControl = require('../annotation-publish-control'); const AnnotationPublishControl = require('../annotation-publish-control');
const { $imports } = require('../annotation-publish-control');
const mockImportedComponents = require('./mock-imported-components'); const mockImportedComponents = require('./mock-imported-components');
describe('AnnotationPublishControl', () => { describe('AnnotationPublishControl', () => {
...@@ -38,14 +39,18 @@ describe('AnnotationPublishControl', () => { ...@@ -38,14 +39,18 @@ describe('AnnotationPublishControl', () => {
fakeApplyTheme = sinon.stub(); fakeApplyTheme = sinon.stub();
AnnotationPublishControl.$imports.$mock(mockImportedComponents()); $imports.$mock(mockImportedComponents());
AnnotationPublishControl.$imports.$mock({ $imports.$mock({
'../util/theme': { '../util/theme': {
applyTheme: fakeApplyTheme, applyTheme: fakeApplyTheme,
}, },
}); });
}); });
afterEach(() => {
$imports.$restore();
});
describe('theming', () => { describe('theming', () => {
it('should apply theme styles', () => { it('should apply theme styles', () => {
const fakeStyle = { foo: 'bar' }; const fakeStyle = { foo: 'bar' };
......
...@@ -2,6 +2,7 @@ const { createElement } = require('preact'); ...@@ -2,6 +2,7 @@ const { createElement } = require('preact');
const { mount } = require('enzyme'); const { mount } = require('enzyme');
const AnnotationQuote = require('../annotation-quote'); const AnnotationQuote = require('../annotation-quote');
const { $imports } = require('../annotation-quote');
const mockImportedComponents = require('./mock-imported-components'); const mockImportedComponents = require('./mock-imported-components');
describe('AnnotationQuote', () => { describe('AnnotationQuote', () => {
...@@ -12,11 +13,11 @@ describe('AnnotationQuote', () => { ...@@ -12,11 +13,11 @@ describe('AnnotationQuote', () => {
} }
beforeEach(() => { beforeEach(() => {
AnnotationQuote.$imports.$mock(mockImportedComponents()); $imports.$mock(mockImportedComponents());
}); });
afterEach(() => { afterEach(() => {
AnnotationQuote.$imports.$restore(); $imports.$restore();
}); });
it('renders the quote', () => { it('renders the quote', () => {
......
...@@ -3,6 +3,7 @@ const { mount } = require('enzyme'); ...@@ -3,6 +3,7 @@ const { mount } = require('enzyme');
const { act } = require('preact/test-utils'); const { act } = require('preact/test-utils');
const AnnotationShareControl = require('../annotation-share-control'); const AnnotationShareControl = require('../annotation-share-control');
const { $imports } = require('../annotation-share-control');
const mockImportedComponents = require('./mock-imported-components'); const mockImportedComponents = require('./mock-imported-components');
describe('AnnotationShareControl', () => { describe('AnnotationShareControl', () => {
...@@ -77,16 +78,16 @@ describe('AnnotationShareControl', () => { ...@@ -77,16 +78,16 @@ describe('AnnotationShareControl', () => {
isShared: sinon.stub().returns(true), isShared: sinon.stub().returns(true),
}; };
fakeShareUri = 'https://www.example.com'; fakeShareUri = 'https://www.example.com';
AnnotationShareControl.$imports.$mock(mockImportedComponents());
AnnotationShareControl.$imports.$mock({ $imports.$mock(mockImportedComponents());
$imports.$mock({
'../util/copy-to-clipboard': fakeCopyToClipboard, '../util/copy-to-clipboard': fakeCopyToClipboard,
'./hooks/use-element-should-close': sinon.stub(), './hooks/use-element-should-close': sinon.stub(),
}); });
}); });
afterEach(() => { afterEach(() => {
AnnotationShareControl.$imports.$restore(); $imports.$restore();
}); });
it('does not render component if `group` prop not OK', () => { it('does not render component if `group` prop not OK', () => {
......
...@@ -4,6 +4,7 @@ const { mount } = require('enzyme'); ...@@ -4,6 +4,7 @@ const { mount } = require('enzyme');
const fixtures = require('../../test/annotation-fixtures'); const fixtures = require('../../test/annotation-fixtures');
const AnnotationShareInfo = require('../annotation-share-info'); const AnnotationShareInfo = require('../annotation-share-info');
const { $imports } = require('../annotation-share-info');
const mockImportedComponents = require('./mock-imported-components'); const mockImportedComponents = require('./mock-imported-components');
describe('AnnotationShareInfo', () => { describe('AnnotationShareInfo', () => {
...@@ -36,14 +37,14 @@ describe('AnnotationShareInfo', () => { ...@@ -36,14 +37,14 @@ describe('AnnotationShareInfo', () => {
isShared: sinon.stub().returns(true), isShared: sinon.stub().returns(true),
}; };
AnnotationShareInfo.$imports.$mock(mockImportedComponents()); $imports.$mock(mockImportedComponents());
AnnotationShareInfo.$imports.$mock({ $imports.$mock({
'../store/use-store': callback => callback(fakeStore), '../store/use-store': callback => callback(fakeStore),
}); });
}); });
afterEach(() => { afterEach(() => {
AnnotationShareInfo.$imports.$restore(); $imports.$restore();
}); });
describe('group link', () => { describe('group link', () => {
......
...@@ -5,6 +5,7 @@ const fixtures = require('../../test/annotation-fixtures'); ...@@ -5,6 +5,7 @@ const fixtures = require('../../test/annotation-fixtures');
const util = require('../../directive/test/util'); const util = require('../../directive/test/util');
const annotationComponent = require('../annotation'); const annotationComponent = require('../annotation');
const { $imports } = require('../annotation');
const inject = angular.mock.inject; const inject = angular.mock.inject;
...@@ -91,13 +92,13 @@ describe('annotation', function() { ...@@ -91,13 +92,13 @@ describe('annotation', function() {
let sandbox; let sandbox;
beforeEach(() => { beforeEach(() => {
annotationComponent.$imports.$mock({ $imports.$mock({
'../util/account-id': fakeAccountID, '../util/account-id': fakeAccountID,
}); });
}); });
afterEach(() => { afterEach(() => {
annotationComponent.$imports.$restore(); $imports.$restore();
}); });
function createDirective(annotation) { function createDirective(annotation) {
......
...@@ -2,6 +2,7 @@ const { createElement } = require('preact'); ...@@ -2,6 +2,7 @@ const { createElement } = require('preact');
const { mount } = require('enzyme'); const { mount } = require('enzyme');
const AnnotationUser = require('../annotation-user'); const AnnotationUser = require('../annotation-user');
const { $imports } = require('../annotation-user');
const mockImportedComponents = require('./mock-imported-components'); const mockImportedComponents = require('./mock-imported-components');
describe('AnnotationUser', () => { describe('AnnotationUser', () => {
...@@ -33,8 +34,8 @@ describe('AnnotationUser', () => { ...@@ -33,8 +34,8 @@ describe('AnnotationUser', () => {
fakeSettings = {}; fakeSettings = {};
fakeUsername = sinon.stub(); fakeUsername = sinon.stub();
AnnotationUser.$imports.$mock(mockImportedComponents()); $imports.$mock(mockImportedComponents());
AnnotationUser.$imports.$mock({ $imports.$mock({
'../util/account-id': { '../util/account-id': {
isThirdPartyUser: fakeIsThirdPartyUser, isThirdPartyUser: fakeIsThirdPartyUser,
username: fakeUsername, username: fakeUsername,
...@@ -43,7 +44,7 @@ describe('AnnotationUser', () => { ...@@ -43,7 +44,7 @@ describe('AnnotationUser', () => {
}); });
afterEach(() => { afterEach(() => {
AnnotationUser.$imports.$restore(); $imports.$restore();
}); });
describe('link to user activity', () => { describe('link to user activity', () => {
......
...@@ -2,6 +2,7 @@ const { createElement } = require('preact'); ...@@ -2,6 +2,7 @@ const { createElement } = require('preact');
const { mount } = require('enzyme'); const { mount } = require('enzyme');
const Button = require('../button'); const Button = require('../button');
const { $imports } = require('../button');
const mockImportedComponents = require('./mock-imported-components'); const mockImportedComponents = require('./mock-imported-components');
describe('Button', () => { describe('Button', () => {
...@@ -21,11 +22,11 @@ describe('Button', () => { ...@@ -21,11 +22,11 @@ describe('Button', () => {
beforeEach(() => { beforeEach(() => {
fakeOnClick = sinon.stub(); fakeOnClick = sinon.stub();
Button.$imports.$mock(mockImportedComponents()); $imports.$mock(mockImportedComponents());
}); });
afterEach(() => { afterEach(() => {
Button.$imports.$restore(); $imports.$restore();
}); });
it('adds active className if `isActive` is `true`', () => { it('adds active className if `isActive` is `true`', () => {
......
...@@ -3,6 +3,7 @@ const { act } = require('preact/test-utils'); ...@@ -3,6 +3,7 @@ const { act } = require('preact/test-utils');
const { mount } = require('enzyme'); const { mount } = require('enzyme');
const Excerpt = require('../excerpt'); const Excerpt = require('../excerpt');
const { $imports } = require('../excerpt');
describe('Excerpt', () => { describe('Excerpt', () => {
const SHORT_DIV = <div id="foo" style="height: 5px;" />; const SHORT_DIV = <div id="foo" style="height: 5px;" />;
...@@ -36,12 +37,13 @@ describe('Excerpt', () => { ...@@ -36,12 +37,13 @@ describe('Excerpt', () => {
container = document.createElement('div'); container = document.createElement('div');
document.body.appendChild(container); document.body.appendChild(container);
Excerpt.$imports.$mock({ $imports.$mock({
'../util/observe-element-size': fakeObserveElementSize, '../util/observe-element-size': fakeObserveElementSize,
}); });
}); });
afterEach(() => { afterEach(() => {
$imports.$restore();
container.remove(); container.remove();
}); });
......
...@@ -2,6 +2,7 @@ const { mount } = require('enzyme'); ...@@ -2,6 +2,7 @@ const { mount } = require('enzyme');
const { createElement } = require('preact'); const { createElement } = require('preact');
const FocusedModeHeader = require('../focused-mode-header'); const FocusedModeHeader = require('../focused-mode-header');
const { $imports } = require('../focused-mode-header');
const mockImportedComponents = require('./mock-imported-components'); const mockImportedComponents = require('./mock-imported-components');
describe('FocusedModeHeader', function() { describe('FocusedModeHeader', function() {
...@@ -24,14 +25,14 @@ describe('FocusedModeHeader', function() { ...@@ -24,14 +25,14 @@ describe('FocusedModeHeader', function() {
setFocusModeFocused: sinon.stub(), setFocusModeFocused: sinon.stub(),
}; };
FocusedModeHeader.$imports.$mock(mockImportedComponents()); $imports.$mock(mockImportedComponents());
FocusedModeHeader.$imports.$mock({ $imports.$mock({
'../store/use-store': callback => callback(fakeStore), '../store/use-store': callback => callback(fakeStore),
}); });
}); });
afterEach(() => { afterEach(() => {
FocusedModeHeader.$imports.$restore(); $imports.$restore();
}); });
context('not in user-focused mode', () => { context('not in user-focused mode', () => {
......
...@@ -3,6 +3,7 @@ const { act } = require('preact/test-utils'); ...@@ -3,6 +3,7 @@ const { act } = require('preact/test-utils');
const { mount } = require('enzyme'); const { mount } = require('enzyme');
const GroupListItem = require('../group-list-item'); const GroupListItem = require('../group-list-item');
const { $imports } = require('../group-list-item');
const { events } = require('../../services/analytics'); const { events } = require('../../services/analytics');
...@@ -65,7 +66,7 @@ describe('GroupListItem', () => { ...@@ -65,7 +66,7 @@ describe('GroupListItem', () => {
} }
FakeSlider.displayName = 'Slider'; FakeSlider.displayName = 'Slider';
GroupListItem.$imports.$mock({ $imports.$mock({
'./menu-item': FakeMenuItem, './menu-item': FakeMenuItem,
'../util/copy-to-clipboard': { '../util/copy-to-clipboard': {
copyText: fakeCopyText, copyText: fakeCopyText,
...@@ -78,7 +79,7 @@ describe('GroupListItem', () => { ...@@ -78,7 +79,7 @@ describe('GroupListItem', () => {
}); });
afterEach(() => { afterEach(() => {
GroupListItem.$imports.$restore(); $imports.$restore();
window.confirm.restore(); window.confirm.restore();
}); });
......
...@@ -2,6 +2,7 @@ const { mount } = require('enzyme'); ...@@ -2,6 +2,7 @@ const { mount } = require('enzyme');
const { createElement } = require('preact'); const { createElement } = require('preact');
const GroupListSection = require('../group-list-section'); const GroupListSection = require('../group-list-section');
const { $imports } = require('../group-list-section');
const mockImportedComponents = require('./mock-imported-components'); const mockImportedComponents = require('./mock-imported-components');
describe('GroupListSection', () => { describe('GroupListSection', () => {
...@@ -27,11 +28,11 @@ describe('GroupListSection', () => { ...@@ -27,11 +28,11 @@ describe('GroupListSection', () => {
}; };
beforeEach(() => { beforeEach(() => {
GroupListSection.$imports.$mock(mockImportedComponents()); $imports.$mock(mockImportedComponents());
}); });
afterEach(() => { afterEach(() => {
GroupListSection.$imports.$restore(); $imports.$restore();
}); });
it('renders heading', () => { it('renders heading', () => {
......
...@@ -3,6 +3,7 @@ const { createElement } = require('preact'); ...@@ -3,6 +3,7 @@ const { createElement } = require('preact');
const { act } = require('preact/test-utils'); const { act } = require('preact/test-utils');
const GroupList = require('../group-list'); const GroupList = require('../group-list');
const { $imports } = require('../group-list');
const mockImportedComponents = require('./mock-imported-components'); const mockImportedComponents = require('./mock-imported-components');
describe('GroupList', () => { describe('GroupList', () => {
...@@ -58,15 +59,15 @@ describe('GroupList', () => { ...@@ -58,15 +59,15 @@ describe('GroupList', () => {
}; };
fakeServiceConfig = sinon.stub().returns(null); fakeServiceConfig = sinon.stub().returns(null);
GroupList.$imports.$mock(mockImportedComponents()); $imports.$mock(mockImportedComponents());
GroupList.$imports.$mock({ $imports.$mock({
'../store/use-store': callback => callback(fakeStore), '../store/use-store': callback => callback(fakeStore),
'../service-config': fakeServiceConfig, '../service-config': fakeServiceConfig,
}); });
}); });
afterEach(() => { afterEach(() => {
GroupList.$imports.$restore(); $imports.$restore();
}); });
it('displays no sections if there are no groups', () => { it('displays no sections if there are no groups', () => {
...@@ -100,7 +101,7 @@ describe('GroupList', () => { ...@@ -100,7 +101,7 @@ describe('GroupList', () => {
const testGroups = populateGroupSections(); const testGroups = populateGroupSections();
const fakeGroupOrganizations = groups => const fakeGroupOrganizations = groups =>
groups.sort((a, b) => a.id.localeCompare(b.id)); groups.sort((a, b) => a.id.localeCompare(b.id));
GroupList.$imports.$mock({ $imports.$mock({
'../util/group-organizations': fakeGroupOrganizations, '../util/group-organizations': fakeGroupOrganizations,
}); });
...@@ -151,7 +152,7 @@ describe('GroupList', () => { ...@@ -151,7 +152,7 @@ describe('GroupList', () => {
}); });
it('displays the group name and icon as static text if there is only one group and no actions available', () => { it('displays the group name and icon as static text if there is only one group and no actions available', () => {
GroupList.$imports.$mock({ $imports.$mock({
'../util/is-third-party-service': () => true, '../util/is-third-party-service': () => true,
}); });
const wrapper = createGroupList(); const wrapper = createGroupList();
......
...@@ -3,6 +3,7 @@ const { createElement } = require('preact'); ...@@ -3,6 +3,7 @@ const { createElement } = require('preact');
const { act } = require('preact/test-utils'); const { act } = require('preact/test-utils');
const HelpPanel = require('../help-panel'); const HelpPanel = require('../help-panel');
const { $imports } = require('../help-panel');
const mockImportedComponents = require('./mock-imported-components'); const mockImportedComponents = require('./mock-imported-components');
describe('HelpPanel', function() { describe('HelpPanel', function() {
...@@ -32,15 +33,15 @@ describe('HelpPanel', function() { ...@@ -32,15 +33,15 @@ describe('HelpPanel', function() {
}; };
fakeVersionData = sinon.stub().returns(fakeVersionDataObject); fakeVersionData = sinon.stub().returns(fakeVersionDataObject);
HelpPanel.$imports.$mock(mockImportedComponents()); $imports.$mock(mockImportedComponents());
HelpPanel.$imports.$mock({ $imports.$mock({
'../store/use-store': callback => callback(fakeStore), '../store/use-store': callback => callback(fakeStore),
'../util/version-data': fakeVersionData, '../util/version-data': fakeVersionData,
}); });
}); });
afterEach(() => { afterEach(() => {
HelpPanel.$imports.$restore(); $imports.$restore();
}); });
context('when viewing tutorial sub-panel', () => { context('when viewing tutorial sub-panel', () => {
......
...@@ -4,6 +4,7 @@ const events = require('../../events'); ...@@ -4,6 +4,7 @@ const events = require('../../events');
const bridgeEvents = require('../../../shared/bridge-events'); const bridgeEvents = require('../../../shared/bridge-events');
const hypothesisApp = require('../hypothesis-app'); const hypothesisApp = require('../hypothesis-app');
const { $imports } = require('../hypothesis-app');
describe('sidebar.components.hypothesis-app', function() { describe('sidebar.components.hypothesis-app', function() {
let $componentController = null; let $componentController = null;
...@@ -44,7 +45,7 @@ describe('sidebar.components.hypothesis-app', function() { ...@@ -44,7 +45,7 @@ describe('sidebar.components.hypothesis-app', function() {
fakeServiceConfig = sandbox.stub(); fakeServiceConfig = sandbox.stub();
fakeShouldAutoDisplayTutorial = sinon.stub().returns(false); fakeShouldAutoDisplayTutorial = sinon.stub().returns(false);
hypothesisApp.$imports.$mock({ $imports.$mock({
'../util/is-sidebar': fakeIsSidebar, '../util/is-sidebar': fakeIsSidebar,
'../service-config': fakeServiceConfig, '../service-config': fakeServiceConfig,
'../util/session': { '../util/session': {
...@@ -56,7 +57,7 @@ describe('sidebar.components.hypothesis-app', function() { ...@@ -56,7 +57,7 @@ describe('sidebar.components.hypothesis-app', function() {
}); });
afterEach(() => { afterEach(() => {
hypothesisApp.$imports.$restore(); $imports.$restore();
}); });
beforeEach(angular.mock.module('h')); beforeEach(angular.mock.module('h'));
......
...@@ -2,6 +2,7 @@ const { createElement } = require('preact'); ...@@ -2,6 +2,7 @@ const { createElement } = require('preact');
const { mount } = require('enzyme'); const { mount } = require('enzyme');
const LoggedOutMessage = require('../logged-out-message'); const LoggedOutMessage = require('../logged-out-message');
const { $imports } = require('../logged-out-message');
const mockImportedComponents = require('./mock-imported-components'); const mockImportedComponents = require('./mock-imported-components');
describe('LoggedOutMessage', () => { describe('LoggedOutMessage', () => {
...@@ -16,11 +17,11 @@ describe('LoggedOutMessage', () => { ...@@ -16,11 +17,11 @@ describe('LoggedOutMessage', () => {
}; };
beforeEach(() => { beforeEach(() => {
LoggedOutMessage.$imports.$mock(mockImportedComponents()); $imports.$mock(mockImportedComponents());
}); });
afterEach(() => { afterEach(() => {
LoggedOutMessage.$imports.$restore(); $imports.$restore();
}); });
it('should link to signup', () => { it('should link to signup', () => {
......
...@@ -4,6 +4,7 @@ const { mount } = require('enzyme'); ...@@ -4,6 +4,7 @@ const { mount } = require('enzyme');
const { LinkType } = require('../../markdown-commands'); const { LinkType } = require('../../markdown-commands');
const MarkdownEditor = require('../markdown-editor'); const MarkdownEditor = require('../markdown-editor');
const { $imports } = require('../markdown-editor');
describe('MarkdownEditor', () => { describe('MarkdownEditor', () => {
const formatResult = { const formatResult = {
...@@ -29,14 +30,14 @@ describe('MarkdownEditor', () => { ...@@ -29,14 +30,14 @@ describe('MarkdownEditor', () => {
return null; return null;
}; };
MarkdownEditor.$imports.$mock({ $imports.$mock({
'../markdown-commands': fakeMarkdownCommands, '../markdown-commands': fakeMarkdownCommands,
'./markdown-view': MarkdownView, './markdown-view': MarkdownView,
}); });
}); });
afterEach(() => { afterEach(() => {
MarkdownEditor.$imports.$restore(); $imports.$restore();
}); });
const commands = [ const commands = [
......
...@@ -2,6 +2,7 @@ const { createElement } = require('preact'); ...@@ -2,6 +2,7 @@ const { createElement } = require('preact');
const { mount } = require('enzyme'); const { mount } = require('enzyme');
const MarkdownView = require('../markdown-view'); const MarkdownView = require('../markdown-view');
const { $imports } = require('../markdown-view');
describe('MarkdownView', () => { describe('MarkdownView', () => {
let fakeMediaEmbedder; let fakeMediaEmbedder;
...@@ -16,14 +17,14 @@ describe('MarkdownView', () => { ...@@ -16,14 +17,14 @@ describe('MarkdownView', () => {
}, },
}; };
MarkdownView.$imports.$mock({ $imports.$mock({
'../render-markdown': fakeRenderMarkdown, '../render-markdown': fakeRenderMarkdown,
'../media-embedder': fakeMediaEmbedder, '../media-embedder': fakeMediaEmbedder,
}); });
}); });
afterEach(() => { afterEach(() => {
MarkdownView.$imports.$restore(); $imports.$restore();
}); });
it('renders nothing if no markdown is provied', () => { it('renders nothing if no markdown is provied', () => {
......
...@@ -2,6 +2,7 @@ const { createElement } = require('preact'); ...@@ -2,6 +2,7 @@ const { createElement } = require('preact');
const { mount } = require('enzyme'); const { mount } = require('enzyme');
const MenuItem = require('../menu-item'); const MenuItem = require('../menu-item');
const { $imports } = require('../menu-item');
const mockImportedComponents = require('./mock-imported-components'); const mockImportedComponents = require('./mock-imported-components');
describe('MenuItem', () => { describe('MenuItem', () => {
...@@ -9,11 +10,11 @@ describe('MenuItem', () => { ...@@ -9,11 +10,11 @@ describe('MenuItem', () => {
mount(<MenuItem label="Test item" {...props} />); mount(<MenuItem label="Test item" {...props} />);
beforeEach(() => { beforeEach(() => {
MenuItem.$imports.$mock(mockImportedComponents()); $imports.$mock(mockImportedComponents());
}); });
afterEach(() => { afterEach(() => {
MenuItem.$imports.$restore(); $imports.$restore();
}); });
it('invokes `onClick` callback when clicked', () => { it('invokes `onClick` callback when clicked', () => {
......
...@@ -2,6 +2,7 @@ const { createElement } = require('preact'); ...@@ -2,6 +2,7 @@ const { createElement } = require('preact');
const { mount } = require('enzyme'); const { mount } = require('enzyme');
const MenuSection = require('../menu-section'); const MenuSection = require('../menu-section');
const { $imports } = require('../menu-section');
const mockImportedComponents = require('./mock-imported-components'); const mockImportedComponents = require('./mock-imported-components');
describe('MenuSection', () => { describe('MenuSection', () => {
...@@ -13,11 +14,11 @@ describe('MenuSection', () => { ...@@ -13,11 +14,11 @@ describe('MenuSection', () => {
); );
beforeEach(() => { beforeEach(() => {
MenuSection.$imports.$mock(mockImportedComponents()); $imports.$mock(mockImportedComponents());
}); });
afterEach(() => { afterEach(() => {
MenuSection.$imports.$restore(); $imports.$restore();
}); });
it('renders the heading', () => { it('renders the heading', () => {
......
...@@ -3,6 +3,7 @@ const { act } = require('preact/test-utils'); ...@@ -3,6 +3,7 @@ const { act } = require('preact/test-utils');
const { mount } = require('enzyme'); const { mount } = require('enzyme');
const Menu = require('../menu'); const Menu = require('../menu');
const { $imports } = require('../menu');
describe('Menu', () => { describe('Menu', () => {
let container; let container;
...@@ -29,14 +30,14 @@ describe('Menu', () => { ...@@ -29,14 +30,14 @@ describe('Menu', () => {
container = document.createElement('div'); container = document.createElement('div');
document.body.appendChild(container); document.body.appendChild(container);
Menu.$imports.$mock({ $imports.$mock({
// eslint-disable-next-line react/display-name // eslint-disable-next-line react/display-name
'./svg-icon': () => <span>Fake SVG icon</span>, './svg-icon': () => <span>Fake SVG icon</span>,
}); });
}); });
afterEach(() => { afterEach(() => {
Menu.$imports.$restore(); $imports.$restore();
container.remove(); container.remove();
}); });
......
...@@ -38,14 +38,16 @@ function getDisplayName(component) { ...@@ -38,14 +38,16 @@ function getDisplayName(component) {
* `Fragment`. * `Fragment`.
* *
* @example * @example
* import ComponentUnderTest, { $imports } from '../component-under-test';
*
* beforeEach(() => { * beforeEach(() => {
* ComponentUnderTest.$imports.$mock(mockImportedComponents()); * $imports.$mock(mockImportedComponents());
* *
* // Add additional mocks or overrides here. * // Add additional mocks or overrides here.
* }); * });
* *
* afterEach(() => { * afterEach(() => {
* ComponentUnderTest.$imports.$restore(); * $imports.$restore();
* }); * });
* *
* @return {Function} - A function that can be passed to `$imports.$mock`. * @return {Function} - A function that can be passed to `$imports.$mock`.
......
...@@ -2,6 +2,7 @@ const { mount } = require('enzyme'); ...@@ -2,6 +2,7 @@ const { mount } = require('enzyme');
const { createElement } = require('preact'); const { createElement } = require('preact');
const ModerationBanner = require('../moderation-banner'); const ModerationBanner = require('../moderation-banner');
const { $imports } = require('../moderation-banner');
const fixtures = require('../../test/annotation-fixtures'); const fixtures = require('../../test/annotation-fixtures');
const mockImportedComponents = require('./mock-imported-components'); const mockImportedComponents = require('./mock-imported-components');
...@@ -29,8 +30,8 @@ describe('ModerationBanner', () => { ...@@ -29,8 +30,8 @@ describe('ModerationBanner', () => {
}, },
}; };
ModerationBanner.$imports.$mock(mockImportedComponents()); $imports.$mock(mockImportedComponents());
ModerationBanner.$imports.$mock({ $imports.$mock({
'../store/use-store': callback => '../store/use-store': callback =>
callback({ callback({
hide: sinon.stub(), hide: sinon.stub(),
...@@ -40,7 +41,7 @@ describe('ModerationBanner', () => { ...@@ -40,7 +41,7 @@ describe('ModerationBanner', () => {
}); });
afterEach(() => { afterEach(() => {
ModerationBanner.$imports.$restore(); $imports.$restore();
}); });
[ [
......
...@@ -4,6 +4,7 @@ const { act } = require('preact/test-utils'); ...@@ -4,6 +4,7 @@ const { act } = require('preact/test-utils');
const events = require('../../events'); const events = require('../../events');
const NewNoteButton = require('../new-note-btn'); const NewNoteButton = require('../new-note-btn');
const { $imports } = require('../new-note-btn');
const mockImportedComponents = require('./mock-imported-components'); const mockImportedComponents = require('./mock-imported-components');
describe('NewNoteButton', function() { describe('NewNoteButton', function() {
...@@ -38,14 +39,14 @@ describe('NewNoteButton', function() { ...@@ -38,14 +39,14 @@ describe('NewNoteButton', function() {
]), ]),
}; };
NewNoteButton.$imports.$mock(mockImportedComponents()); $imports.$mock(mockImportedComponents());
NewNoteButton.$imports.$mock({ $imports.$mock({
'../store/use-store': callback => callback(fakeStore), '../store/use-store': callback => callback(fakeStore),
}); });
}); });
afterEach(() => { afterEach(() => {
NewNoteButton.$imports.$restore(); $imports.$restore();
}); });
it("sets a backgroundColor equal to the setting's ctaBackgroundColor color", () => { it("sets a backgroundColor equal to the setting's ctaBackgroundColor color", () => {
......
...@@ -2,6 +2,7 @@ const { createElement } = require('preact'); ...@@ -2,6 +2,7 @@ const { createElement } = require('preact');
const { mount } = require('enzyme'); const { mount } = require('enzyme');
const SearchInput = require('../search-input'); const SearchInput = require('../search-input');
const { $imports } = require('../search-input');
describe('SearchInput', () => { describe('SearchInput', () => {
let fakeStore; let fakeStore;
...@@ -22,14 +23,14 @@ describe('SearchInput', () => { ...@@ -22,14 +23,14 @@ describe('SearchInput', () => {
const FakeSpinner = () => null; const FakeSpinner = () => null;
FakeSpinner.displayName = 'Spinner'; FakeSpinner.displayName = 'Spinner';
SearchInput.$imports.$mock({ $imports.$mock({
'./spinner': FakeSpinner, './spinner': FakeSpinner,
'../store/use-store': callback => callback(fakeStore), '../store/use-store': callback => callback(fakeStore),
}); });
}); });
afterEach(() => { afterEach(() => {
SearchInput.$imports.$restore(); $imports.$restore();
}); });
it('displays the active query', () => { it('displays the active query', () => {
......
...@@ -2,6 +2,7 @@ const { mount } = require('enzyme'); ...@@ -2,6 +2,7 @@ const { mount } = require('enzyme');
const { createElement } = require('preact'); const { createElement } = require('preact');
const SearchStatusBar = require('../search-status-bar'); const SearchStatusBar = require('../search-status-bar');
const { $imports } = require('../search-status-bar');
const mockImportedComponents = require('./mock-imported-components'); const mockImportedComponents = require('./mock-imported-components');
describe('SearchStatusBar', () => { describe('SearchStatusBar', () => {
...@@ -27,14 +28,14 @@ describe('SearchStatusBar', () => { ...@@ -27,14 +28,14 @@ describe('SearchStatusBar', () => {
noteCount: sinon.stub().returns(0), noteCount: sinon.stub().returns(0),
}; };
SearchStatusBar.$imports.$mock(mockImportedComponents()); $imports.$mock(mockImportedComponents());
SearchStatusBar.$imports.$mock({ $imports.$mock({
'../store/use-store': callback => callback(fakeStore), '../store/use-store': callback => callback(fakeStore),
}); });
}); });
afterEach(() => { afterEach(() => {
SearchStatusBar.$imports.$restore(); $imports.$restore();
}); });
context('user search query is applied', () => { context('user search query is applied', () => {
......
...@@ -3,6 +3,7 @@ const { createElement } = require('preact'); ...@@ -3,6 +3,7 @@ const { createElement } = require('preact');
const uiConstants = require('../../ui-constants'); const uiConstants = require('../../ui-constants');
const SelectionTabs = require('../selection-tabs'); const SelectionTabs = require('../selection-tabs');
const { $imports } = require('../selection-tabs');
const mockImportedComponents = require('./mock-imported-components'); const mockImportedComponents = require('./mock-imported-components');
describe('SelectionTabs', function() { describe('SelectionTabs', function() {
...@@ -39,14 +40,14 @@ describe('SelectionTabs', function() { ...@@ -39,14 +40,14 @@ describe('SelectionTabs', function() {
}), }),
}; };
SelectionTabs.$imports.$mock(mockImportedComponents()); $imports.$mock(mockImportedComponents());
SelectionTabs.$imports.$mock({ $imports.$mock({
'../store/use-store': callback => callback(fakeStore), '../store/use-store': callback => callback(fakeStore),
}); });
}); });
afterEach(() => { afterEach(() => {
SelectionTabs.$imports.$restore(); $imports.$restore();
}); });
const unavailableMessage = wrapper => const unavailableMessage = wrapper =>
......
...@@ -2,6 +2,7 @@ const { createElement } = require('preact'); ...@@ -2,6 +2,7 @@ const { createElement } = require('preact');
const { mount } = require('enzyme'); const { mount } = require('enzyme');
const ShareAnnotationsPanel = require('../share-annotations-panel'); const ShareAnnotationsPanel = require('../share-annotations-panel');
const { $imports } = require('../share-annotations-panel');
const mockImportedComponents = require('./mock-imported-components'); const mockImportedComponents = require('./mock-imported-components');
describe('ShareAnnotationsPanel', () => { describe('ShareAnnotationsPanel', () => {
...@@ -47,15 +48,15 @@ describe('ShareAnnotationsPanel', () => { ...@@ -47,15 +48,15 @@ describe('ShareAnnotationsPanel', () => {
}), }),
}; };
ShareAnnotationsPanel.$imports.$mock(mockImportedComponents()); $imports.$mock(mockImportedComponents());
ShareAnnotationsPanel.$imports.$mock({ $imports.$mock({
'../store/use-store': callback => callback(fakeStore), '../store/use-store': callback => callback(fakeStore),
'../util/copy-to-clipboard': fakeCopyToClipboard, '../util/copy-to-clipboard': fakeCopyToClipboard,
}); });
}); });
afterEach(() => { afterEach(() => {
ShareAnnotationsPanel.$imports.$restore(); $imports.$restore();
}); });
describe('panel title', () => { describe('panel title', () => {
......
...@@ -2,6 +2,7 @@ const { createElement } = require('preact'); ...@@ -2,6 +2,7 @@ const { createElement } = require('preact');
const { mount } = require('enzyme'); const { mount } = require('enzyme');
const ShareLinks = require('../share-links'); const ShareLinks = require('../share-links');
const { $imports } = require('../share-links');
const mockImportedComponents = require('./mock-imported-components'); const mockImportedComponents = require('./mock-imported-components');
describe('ShareLinks', () => { describe('ShareLinks', () => {
...@@ -24,11 +25,11 @@ describe('ShareLinks', () => { ...@@ -24,11 +25,11 @@ describe('ShareLinks', () => {
track: sinon.stub(), track: sinon.stub(),
}; };
ShareLinks.$imports.$mock(mockImportedComponents()); $imports.$mock(mockImportedComponents());
}); });
afterEach(() => { afterEach(() => {
ShareLinks.$imports.$restore(); $imports.$restore();
}); });
const encodedLink = encodeURIComponent(shareLink); const encodedLink = encodeURIComponent(shareLink);
......
...@@ -2,6 +2,7 @@ const { mount } = require('enzyme'); ...@@ -2,6 +2,7 @@ const { mount } = require('enzyme');
const { createElement } = require('preact'); const { createElement } = require('preact');
const SidebarContentError = require('../sidebar-content-error'); const SidebarContentError = require('../sidebar-content-error');
const { $imports } = require('../sidebar-content-error');
const mockImportedComponents = require('./mock-imported-components'); const mockImportedComponents = require('./mock-imported-components');
describe('SidebarContentError', () => { describe('SidebarContentError', () => {
...@@ -21,11 +22,11 @@ describe('SidebarContentError', () => { ...@@ -21,11 +22,11 @@ describe('SidebarContentError', () => {
}; };
beforeEach(() => { beforeEach(() => {
SidebarContentError.$imports.$mock(mockImportedComponents()); $imports.$mock(mockImportedComponents());
}); });
afterEach(() => { afterEach(() => {
SidebarContentError.$imports.$restore(); $imports.$restore();
}); });
it('shows error you may need to login to view message when logged out', () => { it('shows error you may need to login to view message when logged out', () => {
......
...@@ -72,10 +72,6 @@ describe('sidebar.components.sidebar-content', function() { ...@@ -72,10 +72,6 @@ describe('sidebar.components.sidebar-content', function() {
}); });
}); });
afterEach(() => {
sidebarContent.$imports.$restore();
});
function setFrames(frames) { function setFrames(frames) {
frames.forEach(function(frame) { frames.forEach(function(frame) {
store.connectFrame(frame); store.connectFrame(frame);
......
...@@ -2,6 +2,7 @@ const { createElement } = require('preact'); ...@@ -2,6 +2,7 @@ const { createElement } = require('preact');
const { mount } = require('enzyme'); const { mount } = require('enzyme');
const SidebarPanel = require('../sidebar-panel'); const SidebarPanel = require('../sidebar-panel');
const { $imports } = require('../sidebar-panel');
const mockImportedComponents = require('./mock-imported-components'); const mockImportedComponents = require('./mock-imported-components');
describe('SidebarPanel', () => { describe('SidebarPanel', () => {
...@@ -24,15 +25,15 @@ describe('SidebarPanel', () => { ...@@ -24,15 +25,15 @@ describe('SidebarPanel', () => {
toggleSidebarPanel: sinon.stub(), toggleSidebarPanel: sinon.stub(),
}; };
SidebarPanel.$imports.$mock(mockImportedComponents()); $imports.$mock(mockImportedComponents());
SidebarPanel.$imports.$mock({ $imports.$mock({
'../store/use-store': callback => callback(fakeStore), '../store/use-store': callback => callback(fakeStore),
'scroll-into-view': fakeScrollIntoView, 'scroll-into-view': fakeScrollIntoView,
}); });
}); });
afterEach(() => { afterEach(() => {
SidebarPanel.$imports.$restore(); $imports.$restore();
}); });
it('renders the provided title', () => { it('renders the provided title', () => {
......
...@@ -2,6 +2,7 @@ const { createElement } = require('preact'); ...@@ -2,6 +2,7 @@ const { createElement } = require('preact');
const { mount } = require('enzyme'); const { mount } = require('enzyme');
const SortMenu = require('../sort-menu'); const SortMenu = require('../sort-menu');
const { $imports } = require('../sort-menu');
const mockImportedComponents = require('./mock-imported-components'); const mockImportedComponents = require('./mock-imported-components');
describe('SortMenu', () => { describe('SortMenu', () => {
...@@ -24,14 +25,14 @@ describe('SortMenu', () => { ...@@ -24,14 +25,14 @@ describe('SortMenu', () => {
getState: sinon.stub().returns(fakeState), getState: sinon.stub().returns(fakeState),
}; };
SortMenu.$imports.$mock(mockImportedComponents()); $imports.$mock(mockImportedComponents());
SortMenu.$imports.$mock({ $imports.$mock({
'../store/use-store': callback => callback(fakeStore), '../store/use-store': callback => callback(fakeStore),
}); });
}); });
afterEach(() => { afterEach(() => {
SortMenu.$imports.$restore(); $imports.$restore();
}); });
it('renders a menu item for each sort option', () => { it('renders a menu item for each sort option', () => {
......
...@@ -3,6 +3,7 @@ const { createElement } = require('preact'); ...@@ -3,6 +3,7 @@ const { createElement } = require('preact');
const { act } = require('preact/test-utils'); const { act } = require('preact/test-utils');
const StreamSearchInput = require('../stream-search-input'); const StreamSearchInput = require('../stream-search-input');
const { $imports } = require('../stream-search-input');
const mockImportedComponents = require('./mock-imported-components'); const mockImportedComponents = require('./mock-imported-components');
describe('StreamSearchInput', () => { describe('StreamSearchInput', () => {
...@@ -19,11 +20,11 @@ describe('StreamSearchInput', () => { ...@@ -19,11 +20,11 @@ describe('StreamSearchInput', () => {
$on: sinon.stub(), $on: sinon.stub(),
}; };
StreamSearchInput.$imports.$mock(mockImportedComponents()); $imports.$mock(mockImportedComponents());
}); });
afterEach(() => { afterEach(() => {
StreamSearchInput.$imports.$restore(); $imports.$restore();
}); });
function createSearchInput(props = {}) { function createSearchInput(props = {}) {
......
...@@ -3,6 +3,7 @@ const { mount } = require('enzyme'); ...@@ -3,6 +3,7 @@ const { mount } = require('enzyme');
const mockImportedComponents = require('./mock-imported-components'); const mockImportedComponents = require('./mock-imported-components');
const TagEditor = require('../tag-editor'); const TagEditor = require('../tag-editor');
const { $imports } = require('../tag-editor');
describe('TagEditor', function() { describe('TagEditor', function() {
let fakeTags = ['tag1', 'tag2']; let fakeTags = ['tag1', 'tag2'];
...@@ -48,11 +49,11 @@ describe('TagEditor', function() { ...@@ -48,11 +49,11 @@ describe('TagEditor', function() {
store: sinon.stub(), store: sinon.stub(),
}; };
TagEditor.$imports.$mock(mockImportedComponents()); $imports.$mock(mockImportedComponents());
}); });
afterEach(() => { afterEach(() => {
TagEditor.$imports.$restore(); $imports.$restore();
}); });
it('adds appropriate tag values to the elements', () => { it('adds appropriate tag values to the elements', () => {
......
...@@ -3,6 +3,7 @@ const { mount } = require('enzyme'); ...@@ -3,6 +3,7 @@ const { mount } = require('enzyme');
const mockImportedComponents = require('./mock-imported-components'); const mockImportedComponents = require('./mock-imported-components');
const TagList = require('../tag-list'); const TagList = require('../tag-list');
const { $imports } = require('../tag-list');
describe('TagList', function() { describe('TagList', function() {
let fakeServiceUrl; let fakeServiceUrl;
...@@ -27,8 +28,8 @@ describe('TagList', function() { ...@@ -27,8 +28,8 @@ describe('TagList', function() {
fakeServiceUrl = sinon.stub().returns('http://serviceurl.com'); fakeServiceUrl = sinon.stub().returns('http://serviceurl.com');
fakeIsThirdPartyUser = sinon.stub().returns(false); fakeIsThirdPartyUser = sinon.stub().returns(false);
TagList.$imports.$mock(mockImportedComponents()); $imports.$mock(mockImportedComponents());
TagList.$imports.$mock({ $imports.$mock({
'../util/account-id': { '../util/account-id': {
isThirdPartyUser: fakeIsThirdPartyUser, isThirdPartyUser: fakeIsThirdPartyUser,
}, },
...@@ -36,7 +37,7 @@ describe('TagList', function() { ...@@ -36,7 +37,7 @@ describe('TagList', function() {
}); });
afterEach(() => { afterEach(() => {
TagList.$imports.$restore(); $imports.$restore();
}); });
it('does not render any tags if `tags` prop is empty', () => { it('does not render any tags if `tags` prop is empty', () => {
......
...@@ -3,6 +3,7 @@ const { act } = require('preact/test-utils'); ...@@ -3,6 +3,7 @@ const { act } = require('preact/test-utils');
const { mount } = require('enzyme'); const { mount } = require('enzyme');
const Timestamp = require('../timestamp'); const Timestamp = require('../timestamp');
const { $imports } = require('../timestamp');
describe('Timestamp', () => { describe('Timestamp', () => {
let clock; let clock;
...@@ -15,14 +16,14 @@ describe('Timestamp', () => { ...@@ -15,14 +16,14 @@ describe('Timestamp', () => {
decayingInterval: sinon.stub(), decayingInterval: sinon.stub(),
}; };
Timestamp.$imports.$mock({ $imports.$mock({
'../util/time': fakeTime, '../util/time': fakeTime,
}); });
}); });
afterEach(() => { afterEach(() => {
clock.restore(); clock.restore();
Timestamp.$imports.$restore(); $imports.$restore();
}); });
const createTimestamp = props => mount(<Timestamp {...props} />); const createTimestamp = props => mount(<Timestamp {...props} />);
...@@ -104,7 +105,7 @@ describe('Timestamp', () => { ...@@ -104,7 +105,7 @@ describe('Timestamp', () => {
it(`displays an absolute timestamp (${variant})`, () => { it(`displays an absolute timestamp (${variant})`, () => {
const date = new Date('2016-06-10T10:04:04.939Z'); const date = new Date('2016-06-10T10:04:04.939Z');
const format = date => `formatted:${date}`; const format = date => `formatted:${date}`;
Timestamp.$imports.$mock({ $imports.$mock({
'../util/date': { '../util/date': {
format, format,
}, },
......
...@@ -5,6 +5,7 @@ const uiConstants = require('../../ui-constants'); ...@@ -5,6 +5,7 @@ const uiConstants = require('../../ui-constants');
const bridgeEvents = require('../../../shared/bridge-events'); const bridgeEvents = require('../../../shared/bridge-events');
const TopBar = require('../top-bar'); const TopBar = require('../top-bar');
const { $imports } = require('../top-bar');
const mockImportedComponents = require('./mock-imported-components'); const mockImportedComponents = require('./mock-imported-components');
describe('TopBar', () => { describe('TopBar', () => {
...@@ -40,8 +41,8 @@ describe('TopBar', () => { ...@@ -40,8 +41,8 @@ describe('TopBar', () => {
applyPendingUpdates: sinon.stub(), applyPendingUpdates: sinon.stub(),
}; };
TopBar.$imports.$mock(mockImportedComponents()); $imports.$mock(mockImportedComponents());
TopBar.$imports.$mock({ $imports.$mock({
'../store/use-store': callback => callback(fakeStore), '../store/use-store': callback => callback(fakeStore),
'../util/is-third-party-service': fakeIsThirdPartyService, '../util/is-third-party-service': fakeIsThirdPartyService,
'../service-config': fakeServiceConfig, '../service-config': fakeServiceConfig,
...@@ -49,7 +50,7 @@ describe('TopBar', () => { ...@@ -49,7 +50,7 @@ describe('TopBar', () => {
}); });
afterEach(() => { afterEach(() => {
TopBar.$imports.$restore(); $imports.$restore();
}); });
// Helper to retrieve an `Button` by icon name, for convenience // Helper to retrieve an `Button` by icon name, for convenience
......
...@@ -2,6 +2,7 @@ const { mount } = require('enzyme'); ...@@ -2,6 +2,7 @@ const { mount } = require('enzyme');
const { createElement } = require('preact'); const { createElement } = require('preact');
const Tutorial = require('../tutorial'); const Tutorial = require('../tutorial');
const { $imports } = require('../tutorial');
const mockImportedComponents = require('./mock-imported-components'); const mockImportedComponents = require('./mock-imported-components');
describe('Tutorial', function() { describe('Tutorial', function() {
...@@ -14,14 +15,14 @@ describe('Tutorial', function() { ...@@ -14,14 +15,14 @@ describe('Tutorial', function() {
beforeEach(() => { beforeEach(() => {
fakeIsThirdPartyService = sinon.stub().returns(false); fakeIsThirdPartyService = sinon.stub().returns(false);
Tutorial.$imports.$mock(mockImportedComponents()); $imports.$mock(mockImportedComponents());
Tutorial.$imports.$mock({ $imports.$mock({
'../util/is-third-party-service': fakeIsThirdPartyService, '../util/is-third-party-service': fakeIsThirdPartyService,
}); });
}); });
afterEach(() => { afterEach(() => {
Tutorial.$imports.$restore(); $imports.$restore();
}); });
it('should show four "steps" of instructions to first-party users', () => { it('should show four "steps" of instructions to first-party users', () => {
......
...@@ -2,6 +2,7 @@ const { createElement } = require('preact'); ...@@ -2,6 +2,7 @@ const { createElement } = require('preact');
const { mount } = require('enzyme'); const { mount } = require('enzyme');
const UserMenu = require('../user-menu'); const UserMenu = require('../user-menu');
const { $imports } = require('../user-menu');
const mockImportedComponents = require('./mock-imported-components'); const mockImportedComponents = require('./mock-imported-components');
describe('UserMenu', () => { describe('UserMenu', () => {
...@@ -49,8 +50,8 @@ describe('UserMenu', () => { ...@@ -49,8 +50,8 @@ describe('UserMenu', () => {
authDomain: 'hypothes.is', authDomain: 'hypothes.is',
}; };
UserMenu.$imports.$mock(mockImportedComponents()); $imports.$mock(mockImportedComponents());
UserMenu.$imports.$mock({ $imports.$mock({
'../util/account-id': { '../util/account-id': {
isThirdPartyUser: fakeIsThirdPartyUser, isThirdPartyUser: fakeIsThirdPartyUser,
}, },
...@@ -62,7 +63,7 @@ describe('UserMenu', () => { ...@@ -62,7 +63,7 @@ describe('UserMenu', () => {
}); });
afterEach(() => { afterEach(() => {
UserMenu.$imports.$restore(); $imports.$restore();
}); });
describe('profile menu item', () => { describe('profile menu item', () => {
......
...@@ -2,6 +2,7 @@ const { mount } = require('enzyme'); ...@@ -2,6 +2,7 @@ const { mount } = require('enzyme');
const { createElement } = require('preact'); const { createElement } = require('preact');
const VersionInfo = require('../version-info'); const VersionInfo = require('../version-info');
const { $imports } = require('../version-info');
describe('VersionInfo', function() { describe('VersionInfo', function() {
let fakeVersionData; let fakeVersionData;
...@@ -25,7 +26,7 @@ describe('VersionInfo', function() { ...@@ -25,7 +26,7 @@ describe('VersionInfo', function() {
fakeCopyToClipboard = { fakeCopyToClipboard = {
copyText: sinon.stub(), copyText: sinon.stub(),
}; };
VersionInfo.$imports.$mock({ $imports.$mock({
'../util/copy-to-clipboard': fakeCopyToClipboard, '../util/copy-to-clipboard': fakeCopyToClipboard,
}); });
...@@ -40,6 +41,10 @@ describe('VersionInfo', function() { ...@@ -40,6 +41,10 @@ describe('VersionInfo', function() {
fakeVersionData.asFormattedString = sinon.stub().returns('fakeString'); fakeVersionData.asFormattedString = sinon.stub().returns('fakeString');
}); });
afterEach(() => {
$imports.$restore();
});
it('renders `versionData` information', () => { it('renders `versionData` information', () => {
const wrapper = createComponent(); const wrapper = createComponent();
const componentText = wrapper.text(); const componentText = wrapper.text();
......
const annotations = require('../annotations');
const EventEmitter = require('tiny-emitter'); const EventEmitter = require('tiny-emitter');
const annotations = require('../annotations');
const { $imports } = require('../annotations');
let searchClients; let searchClients;
let longRunningSearchClient = false; let longRunningSearchClient = false;
class FakeSearchClient extends EventEmitter { class FakeSearchClient extends EventEmitter {
...@@ -72,14 +74,14 @@ describe('annotations', () => { ...@@ -72,14 +74,14 @@ describe('annotations', () => {
fakeUris = ['http://example.com']; fakeUris = ['http://example.com'];
fakeGroupId = 'group-id'; fakeGroupId = 'group-id';
annotations.$imports.$mock({ $imports.$mock({
'../search-client': FakeSearchClient, '../search-client': FakeSearchClient,
}); });
}); });
afterEach(() => { afterEach(() => {
console.error.restore(); console.error.restore();
annotations.$imports.$restore(); $imports.$restore();
}); });
function service() { function service() {
......
const features = require('../features'); const features = require('../features');
const { $imports } = require('../features');
const events = require('../../events'); const events = require('../../events');
const bridgeEvents = require('../../../shared/bridge-events'); const bridgeEvents = require('../../../shared/bridge-events');
...@@ -38,13 +39,13 @@ describe('h:features - sidebar layer', function() { ...@@ -38,13 +39,13 @@ describe('h:features - sidebar layer', function() {
}, },
}; };
features.$imports.$mock({ $imports.$mock({
'../../shared/warn-once': fakeWarnOnce, '../../shared/warn-once': fakeWarnOnce,
}); });
}); });
afterEach(function() { afterEach(function() {
features.$imports.$restore(); $imports.$restore();
sandbox.restore(); sandbox.restore();
}); });
......
...@@ -5,6 +5,7 @@ const annotationFixtures = require('../../test/annotation-fixtures'); ...@@ -5,6 +5,7 @@ const annotationFixtures = require('../../test/annotation-fixtures');
const events = require('../../events'); const events = require('../../events');
const uiConstants = require('../../ui-constants'); const uiConstants = require('../../ui-constants');
const rootThreadFactory = require('../root-thread'); const rootThreadFactory = require('../root-thread');
const { $imports } = require('../root-thread');
const fixtures = immutable({ const fixtures = immutable({
emptyThread: { emptyThread: {
...@@ -97,13 +98,13 @@ describe('rootThread', function() { ...@@ -97,13 +98,13 @@ describe('rootThread', function() {
}); });
beforeEach(() => { beforeEach(() => {
rootThreadFactory.$imports.$mock({ $imports.$mock({
'../build-thread': fakeBuildThread, '../build-thread': fakeBuildThread,
}); });
}); });
afterEach(() => { afterEach(() => {
rootThreadFactory.$imports.$restore(); $imports.$restore();
}); });
describe('#thread', function() { describe('#thread', function() {
......
const serviceUrlFactory = require('../service-url'); const serviceUrlFactory = require('../service-url');
const { $imports } = require('../service-url');
/** Return a fake store object. */ /** Return a fake store object. */
function fakeStore() { function fakeStore() {
...@@ -18,7 +19,7 @@ function createServiceUrl(linksPromise) { ...@@ -18,7 +19,7 @@ function createServiceUrl(linksPromise) {
.stub() .stub()
.returns({ url: 'EXPANDED_URL', params: {} }); .returns({ url: 'EXPANDED_URL', params: {} });
serviceUrlFactory.$imports.$mock({ $imports.$mock({
'../util/url': { replaceURLParams: replaceURLParams }, '../util/url': { replaceURLParams: replaceURLParams },
}); });
...@@ -43,7 +44,7 @@ describe('sidebar.service-url', function() { ...@@ -43,7 +44,7 @@ describe('sidebar.service-url', function() {
afterEach(function() { afterEach(function() {
console.warn.restore(); console.warn.restore();
serviceUrlFactory.$imports.$restore(); $imports.$restore();
}); });
context('before the API response has been received', function() { context('before the API response has been received', function() {
......
...@@ -2,6 +2,7 @@ const angular = require('angular'); ...@@ -2,6 +2,7 @@ const angular = require('angular');
const events = require('../../events'); const events = require('../../events');
const sessionFactory = require('../session'); const sessionFactory = require('../session');
const { $imports } = require('../session');
const mock = angular.mock; const mock = angular.mock;
...@@ -68,7 +69,7 @@ describe('sidebar.session', function() { ...@@ -68,7 +69,7 @@ describe('sidebar.session', function() {
serviceConfig: fakeServiceConfig, serviceConfig: fakeServiceConfig,
}); });
sessionFactory.$imports.$mock({ $imports.$mock({
'../util/sentry': fakeSentry, '../util/sentry': fakeSentry,
}); });
}); });
...@@ -81,7 +82,7 @@ describe('sidebar.session', function() { ...@@ -81,7 +82,7 @@ describe('sidebar.session', function() {
); );
afterEach(function() { afterEach(function() {
sessionFactory.$imports.$restore(); $imports.$restore();
sandbox.restore(); sandbox.restore();
}); });
......
const EventEmitter = require('tiny-emitter'); const EventEmitter = require('tiny-emitter');
const Streamer = require('../streamer'); const Streamer = require('../streamer');
const { $imports } = require('../streamer');
const fixtures = { const fixtures = {
createNotification: { createNotification: {
...@@ -141,13 +143,13 @@ describe('Streamer', function() { ...@@ -141,13 +143,13 @@ describe('Streamer', function() {
websocketUrl: 'ws://example.com/ws', websocketUrl: 'ws://example.com/ws',
}; };
Streamer.$imports.$mock({ $imports.$mock({
'../websocket': FakeSocket, '../websocket': FakeSocket,
}); });
}); });
afterEach(function() { afterEach(function() {
Streamer.$imports.$restore(); $imports.$restore();
activeStreamer = null; activeStreamer = null;
}); });
......
...@@ -3,6 +3,7 @@ const createStore = require('../../create-store'); ...@@ -3,6 +3,7 @@ const createStore = require('../../create-store');
const annotations = require('../annotations'); const annotations = require('../annotations');
const groups = require('../groups'); const groups = require('../groups');
const realTimeUpdates = require('../real-time-updates'); const realTimeUpdates = require('../real-time-updates');
const { $imports } = require('../real-time-updates');
const selection = require('../selection'); const selection = require('../selection');
const { removeAnnotations } = annotations.actions; const { removeAnnotations } = annotations.actions;
...@@ -25,7 +26,7 @@ describe('sidebar/store/modules/real-time-updates', () => { ...@@ -25,7 +26,7 @@ describe('sidebar/store/modules/real-time-updates', () => {
[fakeSettings] [fakeSettings]
); );
realTimeUpdates.$imports.$mock({ $imports.$mock({
'./annotations': { './annotations': {
selectors: { annotationExists: fakeAnnotationExists }, selectors: { annotationExists: fakeAnnotationExists },
}, },
...@@ -39,7 +40,7 @@ describe('sidebar/store/modules/real-time-updates', () => { ...@@ -39,7 +40,7 @@ describe('sidebar/store/modules/real-time-updates', () => {
}); });
afterEach(() => { afterEach(() => {
realTimeUpdates.$imports.$restore(); $imports.$restore();
}); });
function addPendingUpdates(store) { function addPendingUpdates(store) {
......
const crossOriginRPC = require('../cross-origin-rpc'); const crossOriginRPC = require('../cross-origin-rpc');
const { $imports } = require('../cross-origin-rpc');
describe('crossOriginRPC', function() { describe('crossOriginRPC', function() {
describe('server', function() { describe('server', function() {
...@@ -30,11 +31,15 @@ describe('crossOriginRPC', function() { ...@@ -30,11 +31,15 @@ describe('crossOriginRPC', function() {
fakeWarnOnce = sinon.stub(); fakeWarnOnce = sinon.stub();
crossOriginRPC.$imports.$mock({ $imports.$mock({
'../shared/warn-once': fakeWarnOnce, '../shared/warn-once': fakeWarnOnce,
}); });
}); });
afterEach(() => {
$imports.$restore();
});
/** /**
* Directly call the postMessage() listener func that the server * Directly call the postMessage() listener func that the server
* registered. This simulates what would happen if window.postMessage() * registered. This simulates what would happen if window.postMessage()
......
const renderMarkdown = require('../render-markdown'); const renderMarkdown = require('../render-markdown');
const { $imports } = require('../render-markdown');
describe('render-markdown', function() { describe('render-markdown', function() {
let render; let render;
beforeEach(function() { beforeEach(function() {
renderMarkdown.$imports.$mock({ $imports.$mock({
katex: { katex: {
renderToString: function(input, opts) { renderToString: function(input, opts) {
if (opts && opts.displayMode) { if (opts && opts.displayMode) {
...@@ -21,7 +22,7 @@ describe('render-markdown', function() { ...@@ -21,7 +22,7 @@ describe('render-markdown', function() {
}); });
afterEach(() => { afterEach(() => {
renderMarkdown.$imports.$restore(); $imports.$restore();
}); });
describe('autolinking', function() { describe('autolinking', function() {
......
const VirtualThreadList = require('../virtual-thread-list'); const VirtualThreadList = require('../virtual-thread-list');
const { $imports } = require('../virtual-thread-list');
describe('VirtualThreadList', function() { describe('VirtualThreadList', function() {
let lastState; let lastState;
...@@ -35,13 +36,13 @@ describe('VirtualThreadList', function() { ...@@ -35,13 +36,13 @@ describe('VirtualThreadList', function() {
} }
beforeEach(() => { beforeEach(() => {
VirtualThreadList.$imports.$mock({ $imports.$mock({
'lodash.debounce': fn => fn, 'lodash.debounce': fn => fn,
}); });
}); });
afterEach(() => { afterEach(() => {
VirtualThreadList.$imports.$restore(); $imports.$restore();
}); });
beforeEach(function() { beforeEach(function() {
......
const isThirdPartyService = require('../is-third-party-service'); const isThirdPartyService = require('../is-third-party-service');
const { $imports } = require('../is-third-party-service');
describe('sidebar.util.isThirdPartyService', () => { describe('sidebar.util.isThirdPartyService', () => {
let fakeServiceConfig; let fakeServiceConfig;
...@@ -8,14 +9,14 @@ describe('sidebar.util.isThirdPartyService', () => { ...@@ -8,14 +9,14 @@ describe('sidebar.util.isThirdPartyService', () => {
fakeServiceConfig = sinon.stub(); fakeServiceConfig = sinon.stub();
fakeSettings = { authDomain: 'hypothes.is' }; fakeSettings = { authDomain: 'hypothes.is' };
isThirdPartyService.$imports.$mock({ $imports.$mock({
'../service-config': fakeServiceConfig, '../service-config': fakeServiceConfig,
'@noCallThru': true, '@noCallThru': true,
}); });
}); });
afterEach(() => { afterEach(() => {
isThirdPartyService.$imports.$restore(); $imports.$restore();
}); });
it('returns false for first-party services', () => { it('returns false for first-party services', () => {
......
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