test(floatingLabel): snapshot tests

This commit is contained in:
Adam Bradley
2014-06-13 09:36:14 -05:00
parent 5f1ea5f632
commit 731cf726a9
4 changed files with 68 additions and 6 deletions

View File

@@ -0,0 +1,29 @@
---
name: floatingLabel
component: itemFloatingLabel
---
<ion-header-bar class="bar-positive">
<h1 class="title">
Text Input: Floating Label
</h1>
</ion-header-bar>
<ion-content ng-controller="AppCtrl">
<div class="list">
<label class="item item-input item-floating-label">
<span class="input-label">Name</span>
<input type="text" placeholder="Name">
</label>
<label class="item item-input item-floating-label">
<span class="input-label">Profession</span>
<input type="text" placeholder="Profession">
</label>
<label class="item item-input item-floating-label">
<span class="input-label">Favorite Song</span>
<textarea placeholder="Favorite Song" ng-model="favSong"></textarea>
</label>
</div>
</ion-content>

View File

@@ -0,0 +1,12 @@
---
name: floatingLabel
component: itemFloatingLabel
---
var app = angular.module('floatingLabel', ['ionic']);
app.controller('AppCtrl', function($scope) {
$scope.favSong = "Tubthumping";
});

View File

@@ -0,0 +1,25 @@
---
name: floatingLabel
component: itemFloatingLabel
---
it('should enter text into floating label inputs', function(){
var ele = element.all(by.css('label.item-floating-label input, label.item-floating-label textarea'));
ele.get(0).sendKeys('Dr. Pumpernickel');
ele.get(1).sendKeys('Round House Kicks');
});
it('should add and remove text from floating label inputs', function(){
var ele = element.all(by.css('label.item-floating-label input, label.item-floating-label textarea'));
for(var x=0; x<'Dr. Pumpernickel'.length; x++) {
ele.get(0).sendKeys(protractor.Key.BACK_SPACE);
}
ele.get(1).sendKeys(" To The Face");
for(var x=0; x<'Tubthumping'.length; x++) {
ele.get(2).sendKeys(protractor.Key.BACK_SPACE);
}
});

View File

@@ -11,11 +11,9 @@ IonicModule
if ( !input || !inputLabel ) return;
var onInput = function() {
var hasInput = inputLabel.classList.contains('has-input');
if ( input.value && !hasInput ) {
if ( input.value ) {
inputLabel.classList.add('has-input');
}
else if ( !input.value && hasInput ) {
} else {
inputLabel.classList.remove('has-input');
}
};
@@ -26,8 +24,6 @@ IonicModule
if ( ngModelCtrl ) {
ngModelCtrl.$render = function() {
input.value = ngModelCtrl.$viewValue || '';
if ( ngModelCtrl.$viewValue ) input.value = ngModelCtrl.$viewValue;
else input.value = '';
onInput();
};
}