Commit 5aaaf4e8 authored by Yisu Kim's avatar Yisu Kim Committed by Robert Knight

Add assert to check if details tag is open

parent e05a04ec
...@@ -129,14 +129,12 @@ describe('annotator/util/scroll', () => { ...@@ -129,14 +129,12 @@ describe('annotator/util/scroll', () => {
} }
}); });
// A test for scrolling when there is a target within the 'details' tag. // A test for scrolling when there is a target within the 'details' tag.
it('scrolls element into view when the target is within the details tag',async () => { it('scrolls element into view when the target is within the details tag', async () => {
const container = document.createElement('div'); const container = createContainer();
container.style.height = '500px'; container.style.height = '500px';
container.style.overflow = 'auto'; container.style.overflow = 'auto';
container.style.position = 'relative'; container.style.position = 'relative';
document.body.append(container);
const details = document.createElement('details'); const details = document.createElement('details');
details.style.position = 'absolute'; details.style.position = 'absolute';
...@@ -157,6 +155,7 @@ describe('annotator/util/scroll', () => { ...@@ -157,6 +155,7 @@ describe('annotator/util/scroll', () => {
const containerRect = container.getBoundingClientRect(); const containerRect = container.getBoundingClientRect();
const targetRect = target.getBoundingClientRect(); const targetRect = target.getBoundingClientRect();
assert.isTrue(details.open);
assert.isTrue(containerRect.top <= targetRect.top); assert.isTrue(containerRect.top <= targetRect.top);
assert.isTrue(containerRect.bottom >= targetRect.bottom); assert.isTrue(containerRect.bottom >= targetRect.bottom);
}); });
......
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