mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
test(angular): platform provider
This commit is contained in:
@@ -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');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -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) },
|
||||
|
||||
@@ -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>
|
||||
@@ -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;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user