Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/react/test/base/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const App: React.FC = () => (
<IonApp>
<IonReactRouter>
<IonRouterOutlet>
<Route path="/" component={Main} />
<Route exact path="/" component={Main} />
<Route path="/overlay-hooks" component={OverlayHooks} />
<Route path="/overlay-components" component={OverlayComponents} />
<Route path="/overlay-components/nested-popover" component={IonPopoverNested} />
Expand Down
3 changes: 3 additions & 0 deletions packages/react/test/base/src/pages/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ const Main: React.FC<MainProps> = () => {
<IonItem routerLink="/tabs-basic">
<IonLabel>Tabs with Basic Navigation</IonLabel>
</IonItem>
<IonItem routerLink="/tabs-direct-navigation">
<IonLabel>Tabs with Direct Navigation</IonLabel>
</IonItem>
<IonItem routerLink="/icons">
<IonLabel>Icons</IonLabel>
</IonItem>
Expand Down
26 changes: 14 additions & 12 deletions packages/react/test/base/src/pages/Tabs.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
import React from 'react';
import { IonLabel, IonRouterOutlet, IonTabBar, IonTabButton, IonTabs } from '@ionic/react';
import { IonLabel, IonRouterOutlet, IonTabBar, IonTabButton, IonTabs, IonPage } from '@ionic/react';
import { Route, Redirect } from 'react-router';

interface TabsProps {}

const Tabs: React.FC<TabsProps> = () => {
return (
<IonTabs>
<IonRouterOutlet>
<Redirect from="/tabs" to="/tabs/tab1" exact />
<Route path="/tabs/tab1" render={() => <IonLabel>Tab 1</IonLabel>} />
</IonRouterOutlet>
<IonTabBar slot="bottom">
<IonTabButton tab="tab1" onClick={() => window.alert('Tab was clicked')}>
<IonLabel>Click Handler</IonLabel>
</IonTabButton>
</IonTabBar>
</IonTabs>
<IonPage>
<IonTabs>
<IonRouterOutlet>
<Redirect from="/tabs" to="/tabs/tab1" exact />
<Route path="/tabs/tab1" render={() => <IonLabel>Tab 1</IonLabel>} />
</IonRouterOutlet>
<IonTabBar slot="bottom">
<IonTabButton tab="tab1" onClick={() => window.alert('Tab was clicked')}>
<IonLabel>Click Handler</IonLabel>
</IonTabButton>
</IonTabBar>
</IonTabs>
</IonPage>
);
};

Expand Down
36 changes: 19 additions & 17 deletions packages/react/test/base/src/pages/TabsBasic.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { IonLabel, IonTabBar, IonTabButton, IonTabs, IonTab } from '@ionic/react';
import { IonLabel, IonTabBar, IonTabButton, IonTabs, IonTab, IonPage } from '@ionic/react';

interface TabsProps {}

Expand All @@ -13,22 +13,24 @@ const TabsBasic: React.FC<TabsProps> = () => {
};

return (
<IonTabs onIonTabsWillChange={onTabWillChange} onIonTabsDidChange={onTabDidChange}>
<IonTab tab="tab1">
<IonLabel>Tab 1 Content</IonLabel>
</IonTab>
<IonTab tab="tab2">
<IonLabel>Tab 2 Content</IonLabel>
</IonTab>
<IonTabBar slot="bottom">
<IonTabButton tab="tab1">
<IonLabel>Tab 1</IonLabel>
</IonTabButton>
<IonTabButton tab="tab2">
<IonLabel>Tab 2</IonLabel>
</IonTabButton>
</IonTabBar>
</IonTabs>
<IonPage>
<IonTabs onIonTabsWillChange={onTabWillChange} onIonTabsDidChange={onTabDidChange}>
<IonTab tab="tab1">
<IonLabel>Tab 1 Content</IonLabel>
</IonTab>
<IonTab tab="tab2">
<IonLabel>Tab 2 Content</IonLabel>
</IonTab>
<IonTabBar slot="bottom">
<IonTabButton tab="tab1">
<IonLabel>Tab 1</IonLabel>
</IonTabButton>
<IonTabButton tab="tab2">
<IonLabel>Tab 2</IonLabel>
</IonTabButton>
</IonTabBar>
</IonTabs>
</IonPage>
);
};

Expand Down
8 changes: 4 additions & 4 deletions packages/react/test/base/src/pages/TabsDirectNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,17 @@ const TabsDirectNavigation: React.FC = () => {
</IonTabButton>

<IonTabButton tab="library" href="/tabs-direct-navigation/library" data-testid="library-tab">
<IonIcon icon={libraryOutline}></IonIcon>
<IonIcon icon={libraryOutline}></IonIcon>
<IonLabel>Library</IonLabel>
</IonTabButton>

<IonTabButton tab="search" href="/tabs-direct-navigation/search" data-testid="search-tab">
<IonIcon icon={searchOutline}></IonIcon>
<IonLabel>Search</IonLabel>
</IonTabButton>
</IonTabBar>
</IonTabs>
</IonTabBar>
</IonTabs>
);
};

export default TabsDirectNavigation;
export default TabsDirectNavigation;
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@ describe('Tabs Direct Navigation', () => {
it('should update tab selection when navigating between tabs', () => {
cy.visit('/tabs-direct-navigation/home');
cy.get('[data-testid="home-tab"]').should('have.class', 'tab-selected');

cy.get('[data-testid="radio-tab"]').click();
cy.get('[data-testid="radio-tab"]').should('have.class', 'tab-selected');
cy.get('[data-testid="home-tab"]').should('not.have.class', 'tab-selected');
cy.get('[data-testid="radio-content"]').should('be.visible');
});
});
});
Loading