mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
popup snapshot
This commit is contained in:
31
ionic/components/popup/test/basic/e2e.ts
Normal file
31
ionic/components/popup/test/basic/e2e.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
it('should open alert', function() {
|
||||
element(by.css('#e2eOpenAlert')).click();
|
||||
});
|
||||
|
||||
|
||||
it('should close alert', function() {
|
||||
element(by.css('.popup-buttons button:last-of-type')).click();
|
||||
});
|
||||
|
||||
|
||||
it('should open prompt', function() {
|
||||
element(by.css('#e2eOpenPrompt')).click();
|
||||
});
|
||||
|
||||
|
||||
it('should close prompt', function() {
|
||||
var inputEle = element(by.css('.popup-body input'));
|
||||
inputEle.sendKeys('prompt text');
|
||||
element(by.css('.popup-buttons button:last-of-type')).click();
|
||||
});
|
||||
|
||||
|
||||
it('should open confirm', function() {
|
||||
element(by.css('#e2eOpenConfirm')).click();
|
||||
});
|
||||
|
||||
|
||||
it('should close confirm', function() {
|
||||
element(by.css('.popup-buttons button:last-of-type')).click();
|
||||
});
|
||||
@@ -1,35 +1,46 @@
|
||||
import {App, IonicView, IonicApp, IonicConfig, Platform} from 'ionic/ionic';
|
||||
import {Popup} from 'ionic/ionic';
|
||||
import {App, Popup} from 'ionic/ionic';
|
||||
|
||||
|
||||
@App({
|
||||
templateUrl: 'main.html'
|
||||
})
|
||||
class MyAppCmp {
|
||||
class E2EApp {
|
||||
|
||||
constructor(popup: Popup, app: IonicApp, ionicConfig: IonicConfig) {
|
||||
constructor(popup: Popup) {
|
||||
this.popup = popup;
|
||||
|
||||
this.alertOpen = false;
|
||||
this.promptOpen = false;
|
||||
this.promptResult = '';
|
||||
this.confirmOpen = false;
|
||||
this.confirmResult = '';
|
||||
}
|
||||
|
||||
doAlert() {
|
||||
this.popup.alert('What!?').then(() => {
|
||||
}, () => {
|
||||
this.alertOpen = true;
|
||||
this.popup.alert('Alert').then(() => {
|
||||
this.alertOpen = false;
|
||||
});
|
||||
}
|
||||
|
||||
doPrompt() {
|
||||
this.popup.prompt('What is your name?').then((name, event) => {
|
||||
console.log('Got response', name);
|
||||
this.promptOpen = true;
|
||||
this.popup.prompt('What is your name?').then((name) => {
|
||||
this.promptResult = name;
|
||||
this.promptOpen = false;
|
||||
}, () => {
|
||||
console.error('Prompt closed');
|
||||
this.promptOpen = false;
|
||||
});
|
||||
}
|
||||
|
||||
doConfirm() {
|
||||
this.popup.confirm('Are you sure?').then((yes, event) => {
|
||||
console.log('CONFIRMED', yes);
|
||||
this.confirmOpen = true;
|
||||
this.popup.confirm('Are you sure?').then((result, ev) => {
|
||||
console.log('CONFIRMED', result);
|
||||
this.confirmResult = result;
|
||||
this.confirmOpen = false;
|
||||
}, () => {
|
||||
this.confirmOpen = false;
|
||||
console.error('NOT CONFIRMED');
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,6 +1,16 @@
|
||||
|
||||
<ion-content class="padding">
|
||||
<button primary (click)="doAlert()">Alert</button>
|
||||
<button primary (click)="doPrompt()">Prompt</button>
|
||||
<button primary (click)="doConfirm()">Confirm</button>
|
||||
<button primary (click)="doCustom()">Custom</button>
|
||||
|
||||
<button id="e2eOpenAlert" primary (click)="doAlert()">Alert</button>
|
||||
<button id="e2eOpenPrompt" primary (click)="doPrompt()">Prompt</button>
|
||||
<button id="e2eOpenConfirm" primary (click)="doConfirm()">Confirm</button>
|
||||
|
||||
<pre>
|
||||
Alert Opened: {{alertOpen}}
|
||||
Prompt Opened: {{promptOpen}}
|
||||
Prompt Result: {{promptResult}}
|
||||
Confirm Opened: {{confirmOpen}}
|
||||
Confirm Result: {{confirmResult}}
|
||||
</pre>
|
||||
|
||||
</ion-content>
|
||||
|
||||
Reference in New Issue
Block a user