Commit 0330166c authored by Eduardo Sanz García's avatar Eduardo Sanz García Committed by Eduardo

Remove elements created during test

parent 63545fd3
......@@ -77,6 +77,7 @@ describe('HTMLIntegration', () => {
const highlight = document.createElement('div');
document.body.appendChild(highlight);
try {
const anchor = { highlights: [highlight] };
const integration = new HTMLIntegration();
......@@ -84,6 +85,9 @@ describe('HTMLIntegration', () => {
assert.calledOnce(fakeScrollIntoView);
assert.calledWith(fakeScrollIntoView, highlight, sinon.match.func);
} finally {
highlight.remove();
}
});
});
......
......@@ -104,6 +104,7 @@ describe('annotator/integrations/pdf', () => {
pdfIntegration?.destroy();
delete window.PDFViewerApplication;
outerContainer.remove();
document.querySelector('hypothesis-banner')?.remove(); // <hypothesis-banner> elements are created outside the outerContainer
$imports.$restore();
});
......@@ -288,11 +289,16 @@ describe('annotator/integrations/pdf', () => {
pdfIntegration = createPDFIntegration();
document.body.appendChild(anchor.highlights[0]);
try {
await triggerUpdate();
assert.equal(anchor.highlights.length, 1);
assert.ok(anchor.range);
assert.notCalled(fakeAnnotator.anchor);
} finally {
anchor.highlights[0].remove();
}
});
});
......
......@@ -14,6 +14,11 @@ describe('sidebarTrigger', () => {
document.body.appendChild(triggerEl2);
});
afterEach(() => {
triggerEl1.remove();
triggerEl2.remove();
});
it('calls the show callback which a trigger button is clicked', () => {
const fakeShowFn = sinon.stub();
sidebarTrigger(document, fakeShowFn);
......
......@@ -11,6 +11,10 @@ describe('sidebar/util/dom', () => {
document.body.appendChild(theElement);
});
afterEach(() => {
theElement.remove();
});
it("should return an element's height", () => {
const testElement = document.getElementById('testElement');
assert.equal(getElementHeightWithMargins(testElement), 450);
......
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