popup snapshot

This commit is contained in:
Adam Bradley
2015-07-28 15:45:26 -05:00
parent 51516b8b64
commit 39b1d208ef
3 changed files with 67 additions and 15 deletions

View 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();
});

View File

@@ -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');
});
}

View File

@@ -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>