Skip to content

Commit

Permalink
test: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mlmoravek committed Dec 9, 2024
1 parent d8d7183 commit dce65c3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/oruga/src/components/tabs/TabItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const providedData = computed<TabItemComponent<T>>(() => ({
value: itemValue,
$slots: slots,
navClasses: navItemClasses.value,
classes: tabClasses.value,
tabClasses: tabClasses.value,
iconClasses: tabIconClasses.value,
labelClasses: tabLabelClasses.value,
isTransitioning: isTransitioning.value,
Expand Down
18 changes: 10 additions & 8 deletions packages/oruga/src/components/tabs/tests/tabs.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe("OTab with OTabItem tests", () => {

test("renders the tab buttons", async () => {
const wrapper = mount(componentWrapper);
await wrapper.vm.$nextTick();
await nextTick();

const tabButtons = wrapper.findAll(".o-tabs__nav-item");

Expand All @@ -81,7 +81,7 @@ describe("OTab with OTabItem tests", () => {

test("renders the tab panels", async () => {
const wrapper = mount(componentWrapper, { attachTo: document.body });
await wrapper.vm.$nextTick();
await nextTick();

const tabPanls = wrapper.findAll(`[data-oruga="tabs-item"]`);

Expand All @@ -96,22 +96,24 @@ describe("OTab with OTabItem tests", () => {

test("switches the content based on the tab clicked", async () => {
const wrapper = mount(componentWrapper, { attachTo: document.body });
await wrapper.vm.$nextTick();
await nextTick();

const tabs = wrapper.findAll(".o-tabs__tab");
const tabPanls = wrapper.findAll(`[data-oruga="tabs-item"]`);
const tabPanels = wrapper.findAll(`[data-oruga="tabs-item"]`);
expect(tabs).toHaveLength(3);
expect(tabPanels).toHaveLength(3);

// clicking the second tab reveals the second content
// and hides the first content
await tabs[1].trigger("click");
expect(tabPanls[1].isVisible()).toBeTruthy();
expect(tabPanls[0].isVisible()).toBeFalsy();
expect(tabPanels[1].isVisible()).toBeTruthy();
expect(tabPanels[0].isVisible()).toBeFalsy();

// clicking the third tab reveals the third content
// and hides the second content
await tabs[2].trigger("click");
expect(tabPanls[2].isVisible()).toBeTruthy();
expect(tabPanls[1].isVisible()).toBeFalsy();
expect(tabPanels[2].isVisible()).toBeTruthy();
expect(tabPanels[1].isVisible()).toBeFalsy();
});

test("render item with component prop correctly", () => {
Expand Down

0 comments on commit dce65c3

Please sign in to comment.