mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
test(floatingLabel): snapshot tests
This commit is contained in:
29
demos/directive/textInput/floatingLabel/index.html
Normal file
29
demos/directive/textInput/floatingLabel/index.html
Normal 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>
|
||||
12
demos/directive/textInput/floatingLabel/index.js
Normal file
12
demos/directive/textInput/floatingLabel/index.js
Normal file
@@ -0,0 +1,12 @@
|
||||
---
|
||||
name: floatingLabel
|
||||
component: itemFloatingLabel
|
||||
---
|
||||
|
||||
var app = angular.module('floatingLabel', ['ionic']);
|
||||
|
||||
app.controller('AppCtrl', function($scope) {
|
||||
|
||||
$scope.favSong = "Tubthumping";
|
||||
|
||||
});
|
||||
25
demos/directive/textInput/floatingLabel/test.scenario.js
Normal file
25
demos/directive/textInput/floatingLabel/test.scenario.js
Normal 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);
|
||||
}
|
||||
|
||||
});
|
||||
8
js/angular/directive/itemFloatingLabel.js
vendored
8
js/angular/directive/itemFloatingLabel.js
vendored
@@ -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();
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user