test(angular): platform provider

This commit is contained in:
Sean Perkins
2023-11-06 15:24:17 -05:00
parent d418bb2f9f
commit 6a9fe5b2c1
4 changed files with 65 additions and 0 deletions

View File

@@ -9,3 +9,17 @@ describe('Providers', () => {
cy.get('#keyboard-height').should('have.text', '12345');
});
})
describe('Providers: Platform', () => {
beforeEach(() => {
cy.visit('/standalone/providers/platform');
});
it('isReady should be true', () => {
cy.ionPageVisible('app-platform');
cy.get('#is-ready').should('have.text', 'true');
});
});

View File

@@ -14,6 +14,7 @@ export const routes: Routes = [
{ path: 'router-link', loadComponent: () => import('../router-link/router-link.component').then(c => c.RouterLinkComponent) },
{ path: 'nav', loadComponent: () => import('../nav/nav.component').then(c => c.NavComponent) },
{ path: 'providers', loadComponent: () => import('../providers/providers.component').then(c => c.ProvidersComponent) },
{ path: 'providers/platform', loadComponent: () => import('../platform/platform.component').then(c => c.PlatformComponent) },
{ path: 'overlay-controllers', loadComponent: () => import('../overlay-controllers/overlay-controllers.component').then(c => c.OverlayControllersComponent) },
{ path: 'button', loadComponent: () => import('../button/button.component').then(c => c.ButtonComponent) },
{ path: 'icon', loadComponent: () => import('../icon/icon.component').then(c => c.IconComponent) },

View File

@@ -0,0 +1,11 @@
<ul>
<li>
isReady: <span id="is-ready">{{ isReady }}</span>
</li>
<li>
isResumed: <span id="is-resumed">{{ isResumed }}</span>
</li>
<li>
isPaused: <span id="is-paused">{{ isPaused }}</span>
</li>
</ul>

View File

@@ -0,0 +1,39 @@
import { Component, NgZone } from "@angular/core";
import { Platform } from '@ionic/angular/standalone';
@Component({
selector: "app-platform",
templateUrl: "./platform.component.html",
standalone: true
})
export class PlatformComponent {
isReady = false;
isResumed = false;
isPaused = false;
isResized = false;
constructor(public platform: Platform) {
platform.ready().then(() => {
NgZone.assertInAngularZone();
this.isReady = true;
});
platform.resume.subscribe(() => {
console.log('platform:resume');
NgZone.assertInAngularZone();
this.isResumed = true;
});
platform.pause.subscribe(() => {
console.log('platform:pause');
NgZone.assertInAngularZone();
this.isPaused = true;
});
platform.resize.subscribe(() => {
console.log('platform:resize');
NgZone.assertInAngularZone();
this.isResized = true;
});
}
}