Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thednp committed Nov 7, 2024
1 parent 2ef776b commit d615103
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
4 changes: 3 additions & 1 deletion src/util/scrollbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ export const setScrollbar = (element: Element, overflow?: boolean) => {
const bd = getDocumentBody(element);
const bodyPad = parseInt(getElementStyle(bd, "paddingRight"), 10);
const isOpen = getElementStyle(bd, "overflow") === "hidden";
const sbWidth = isOpen && bodyPad ? 0 : measureScrollbar(element);
const sbWidth = isOpen && bodyPad
? /* istanbul ignore next */ 0
: measureScrollbar(element);
const fixedItems = getFixedItems(bd);

// istanbul ignore if @preserve
Expand Down
2 changes: 1 addition & 1 deletion test/assets/bootstrap.min.css
Original file line number Diff line number Diff line change
Expand Up @@ -11482,7 +11482,7 @@ textarea.form-control-lg {
.fade,
.collapsing,
.carousel-item {
transition-duration: 100ms;
transition-duration: 50ms;
}

.modal, .offcanvas, .tooltip, .popover { transition-duration: 0.05s }
Expand Down
1 change: 1 addition & 0 deletions test/offcanvas.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ describe("Offcanvas Class Tests", () => {
await vi.waitFor(() => {
expect(instance.element.className).to.contain("show");
}, 151);
await new Promise(res => setTimeout(res, 151));

dismiss.click();
await vi.waitFor(() => {
Expand Down
21 changes: 11 additions & 10 deletions test/tab.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,39 +78,40 @@ describe("Tab Class Tests", () => {
dropdowns.forEach(dropdown => dropdownInstances.push(Dropdown.init(dropdown)));
elements.forEach(element => tabInstances.push(Tab.init(element)));

(dropdownInstances[0].element as HTMLElement).click();
dropdownInstances[0].element.click();
await vi.waitFor(() => {
expect(dropdownInstances[0].menu.className).to.contain('show');
}, 50);
(tabInstances[1].element as HTMLElement).click();
}, 150);
tabInstances[1].element.click();
await vi.waitFor(() => {
expect(tabInstances[0].content?.className).to.not.contain('show');
expect(tabInstances[1].content?.className).to.contain('show');
}, 151);

await new Promise(res => setTimeout(res, 101));
(dropdownInstances[0].element as HTMLElement).click();
dropdownInstances[0].element.click();
await vi.waitFor(() => {
expect(dropdownInstances[0].menu.className).to.contain('show');
}, 50);
}, 150);

await new Promise(res => setTimeout(res, 171));
(tabInstances[2].element as HTMLElement).click();
tabInstances[2].element.click();
await vi.waitFor(() => {
expect(tabInstances[1].content?.className).to.not.contain('show');
expect(tabInstances[2].content?.className).to.contain('show');
}, 151);
}, 171);

await new Promise(res => setTimeout(res, 101));
(tabInstances[4].element as HTMLElement).click();
tabInstances[4].element.click();
await vi.waitFor(() => {
expect(tabInstances[4].content?.className).to.contain('show');
}, 151);

(tabInstances[3].element as HTMLElement).click();
tabInstances[3].element.click();
await vi.waitFor(() => {
expect(tabInstances[4].content?.className).to.not.contain('show');
expect(tabInstances[3].content?.className).to.contain('show');
}, 151);
}, 171);
});

it("Can do original events", async () => {
Expand Down

0 comments on commit d615103

Please sign in to comment.