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', () => {
let fakeSuggestedFilename;
let fakeCopyPlainText;
let fakeCopyHTML;
let wrappers;
const fakePrivateGroup = {
type: 'private',
......@@ -25,16 +26,20 @@ describe('ExportAnnotations', () => {
id: 'testprivate',
};
const createComponent = props =>
mount(
const createComponent = props => {
const wrapper = mount(
<ExportAnnotations
annotationsExporter={fakeAnnotationsExporter}
toastMessenger={fakeToastMessenger}
{...props}
/>,
);
wrappers.push(wrapper);
return wrapper;
};
beforeEach(() => {
wrappers = [];
fakeAnnotationsExporter = {
buildJSONExportContent: sinon.stub().returns({}),
buildTextExportContent: sinon.stub().returns(''),
......@@ -90,6 +95,7 @@ describe('ExportAnnotations', () => {
});
afterEach(() => {
wrappers.forEach(w => w.unmount());
$imports.$restore();
});
......
......@@ -12,8 +12,11 @@ describe('ImportAnnotations', () => {
let fakeImportAnnotationsService;
let fakeReadExportFile;
let fakeStore;
let wrappers;
beforeEach(() => {
wrappers = [];
fakeReadExportFile = sinon.stub().rejects(new Error('Failed to read file'));
fakeImportAnnotationsService = {
......@@ -39,16 +42,19 @@ describe('ImportAnnotations', () => {
});
afterEach(() => {
wrappers.forEach(w => w.unmount());
$imports.$restore();
});
function createImportAnnotations() {
return mount(
const wrapper = mount(
<ImportAnnotations
store={fakeStore}
importAnnotationsService={fakeImportAnnotationsService}
/>,
);
wrappers.push(wrapper);
return 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