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