Commit 52d8eed2 authored by Robert Knight's avatar Robert Knight

Use `mockImportedComponents` in several additional tests

For consistency with other tests, use `mockImportedComponents` so that
an issue with an imported component doesn't cause a cascade of failures
in the unit tests for these components.
parent f593f98b
......@@ -6,6 +6,7 @@ import { LinkType } from '../../markdown-commands';
import MarkdownEditor from '../markdown-editor';
import { $imports } from '../markdown-editor';
import mockImportedComponents from '../../../test-util/mock-imported-components';
import { checkAccessibility } from '../../../test-util/accessibility';
describe('MarkdownEditor', () => {
......@@ -32,6 +33,7 @@ describe('MarkdownEditor', () => {
return null;
};
$imports.$mock(mockImportedComponents());
$imports.$mock({
'../markdown-commands': fakeMarkdownCommands,
'./markdown-view': MarkdownView,
......
......@@ -4,6 +4,7 @@ import { createElement } from 'preact';
import SearchInput from '../search-input';
import { $imports } from '../search-input';
import mockImportedComponents from '../../../test-util/mock-imported-components';
import { checkAccessibility } from '../../../test-util/accessibility';
describe('SearchInput', () => {
......@@ -22,11 +23,8 @@ describe('SearchInput', () => {
beforeEach(() => {
fakeStore = { isLoading: sinon.stub().returns(false) };
const FakeSpinner = () => null;
FakeSpinner.displayName = 'Spinner';
$imports.$mock(mockImportedComponents());
$imports.$mock({
'./spinner': FakeSpinner,
'../store/use-store': callback => callback(fakeStore),
});
});
......@@ -84,7 +82,7 @@ describe('SearchInput', () => {
it('renders search button when app is not in "loading" state', () => {
fakeStore.isLoading.returns(false);
const wrapper = createSearchInput();
assert.isTrue(wrapper.exists('button'));
assert.isTrue(wrapper.exists('Button'));
});
it(
......
......@@ -4,6 +4,7 @@ import { createElement } from 'preact';
import VersionInfo from '../version-info';
import { $imports } from '../version-info';
import mockImportedComponents from '../../../test-util/mock-imported-components';
import { checkAccessibility } from '../../../test-util/accessibility';
describe('VersionInfo', function () {
......@@ -32,6 +33,7 @@ describe('VersionInfo', function () {
fakeCopyToClipboard = {
copyText: sinon.stub(),
};
$imports.$mock(mockImportedComponents());
$imports.$mock({
'../util/copy-to-clipboard': fakeCopyToClipboard,
});
......@@ -65,7 +67,7 @@ describe('VersionInfo', function () {
it('copies version info to clipboard when copy button clicked', () => {
const wrapper = createComponent();
wrapper.find('button').simulate('click');
wrapper.find('Button').props().onClick();
assert.calledWith(fakeCopyToClipboard.copyText, 'fakeString');
});
......@@ -73,7 +75,7 @@ describe('VersionInfo', function () {
it('confirms info copy when successful', () => {
const wrapper = createComponent();
wrapper.find('button').simulate('click');
wrapper.find('Button').props().onClick();
assert.calledWith(
fakeToastMessenger.success,
......@@ -85,7 +87,7 @@ describe('VersionInfo', function () {
fakeCopyToClipboard.copyText.throws();
const wrapper = createComponent();
wrapper.find('button').simulate('click');
wrapper.find('Button').props().onClick();
assert.calledWith(
fakeToastMessenger.error,
......
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