<!doctype html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Example - example-number-input-directive-production</title>
  

  <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.8/angular.min.js"></script>
  

  
</head>
<body ng-app="numberExample">
  <script>
  angular.module('numberExample', [])
    .controller('ExampleController', ['$scope', function($scope) {
      $scope.value = 12;
      $scope.message = "";
      
      $scope.$watch('value', function(newValue, oldValue) {
        $scope.message = '$scope.value changed to ' + String(newValue) + ' from ' + String(oldValue);
      });
    }]);
</script>
<form name="myForm" ng-controller="ExampleController">
  Number: <input type="number" name="input" ng-model="value">
  <span class="error" ng-show="myForm.input.$error.number">
    Not valid number!</span>
  <tt>value = {{value}}</tt><br/>
  <tt>myForm.input.$valid = {{myForm.input.$valid}}</tt><br/>
  <tt>myForm.input.$error = {{myForm.input.$error}}</tt><br/>
  <tt>myForm.$valid = {{myForm.$valid}}</tt><br/>
  <tt>$scope.value: {{value === undefined ? "undefined": value}}</tt>
  
  <p>{{message}}</p>
 </form>
</body>
</html>
var value = element(by.binding('value'));
var valid = element(by.binding('myForm.input.$valid'));
var input = element(by.model('value'));

it('should initialize to model', function() {
  expect(value.getText()).toContain('12');
  expect(valid.getText()).toContain('true');
});

it('should be invalid if empty', function() {
  input.clear();
  input.sendKeys('');
  expect(value.getText()).toEqual('value =');
  expect(valid.getText()).toContain('false');
});

it('should be invalid if over max', function() {
  input.clear();
  input.sendKeys('123');
  expect(value.getText()).toEqual('value =');
  expect(valid.getText()).toContain('false');
});