Commit 97dd7e38 authored by Robert Knight's avatar Robert Knight

Unmount ImportAnnotations, ExportAnnotations components at end of test

This fixes an issue where `SelectNext`s rendered by these components could open
a popover, and then trigger an error by trying to close it, while unmounted, in
response to an action triggered by a later test.
parent 4033b11f
...@@ -18,6 +18,7 @@ describe('ExportAnnotations', () => { ...@@ -18,6 +18,7 @@ describe('ExportAnnotations', () => {
let fakeSuggestedFilename; let fakeSuggestedFilename;
let fakeCopyPlainText; let fakeCopyPlainText;
let fakeCopyHTML; let fakeCopyHTML;
let wrappers;
const fakePrivateGroup = { const fakePrivateGroup = {
type: 'private', type: 'private',
...@@ -25,16 +26,20 @@ describe('ExportAnnotations', () => { ...@@ -25,16 +26,20 @@ describe('ExportAnnotations', () => {
id: 'testprivate', id: 'testprivate',
}; };
const createComponent = props => const createComponent = props => {
mount( const wrapper = mount(
<ExportAnnotations <ExportAnnotations
annotationsExporter={fakeAnnotationsExporter} annotationsExporter={fakeAnnotationsExporter}
toastMessenger={fakeToastMessenger} toastMessenger={fakeToastMessenger}
{...props} {...props}
/>, />,
); );
wrappers.push(wrapper);
return wrapper;
};
beforeEach(() => { beforeEach(() => {
wrappers = [];
fakeAnnotationsExporter = { fakeAnnotationsExporter = {
buildJSONExportContent: sinon.stub().returns({}), buildJSONExportContent: sinon.stub().returns({}),
buildTextExportContent: sinon.stub().returns(''), buildTextExportContent: sinon.stub().returns(''),
...@@ -90,6 +95,7 @@ describe('ExportAnnotations', () => { ...@@ -90,6 +95,7 @@ describe('ExportAnnotations', () => {
}); });
afterEach(() => { afterEach(() => {
wrappers.forEach(w => w.unmount());
$imports.$restore(); $imports.$restore();
}); });
......
...@@ -12,8 +12,11 @@ describe('ImportAnnotations', () => { ...@@ -12,8 +12,11 @@ describe('ImportAnnotations', () => {
let fakeImportAnnotationsService; let fakeImportAnnotationsService;
let fakeReadExportFile; let fakeReadExportFile;
let fakeStore; let fakeStore;
let wrappers;
beforeEach(() => { beforeEach(() => {
wrappers = [];
fakeReadExportFile = sinon.stub().rejects(new Error('Failed to read file')); fakeReadExportFile = sinon.stub().rejects(new Error('Failed to read file'));
fakeImportAnnotationsService = { fakeImportAnnotationsService = {
...@@ -39,16 +42,19 @@ describe('ImportAnnotations', () => { ...@@ -39,16 +42,19 @@ describe('ImportAnnotations', () => {
}); });
afterEach(() => { afterEach(() => {
wrappers.forEach(w => w.unmount());
$imports.$restore(); $imports.$restore();
}); });
function createImportAnnotations() { function createImportAnnotations() {
return mount( const wrapper = mount(
<ImportAnnotations <ImportAnnotations
store={fakeStore} store={fakeStore}
importAnnotationsService={fakeImportAnnotationsService} importAnnotationsService={fakeImportAnnotationsService}
/>, />,
); );
wrappers.push(wrapper);
return wrapper;
} }
function getImportButton(wrapper) { function getImportButton(wrapper) {
......
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