Repository: angular/angular.js
File: test/ng/directive/inputSpec.js (JavaScript)

Code before:
          $rootScope.value = new Date(Date.UTC(20456, 3, 1, 0, 0, 0));
        });
        expect(inputElm.val()).toBe('20456-04');
      });
    }


    it('should only change the month of a bound date', function() {
      var inputElm = helper.compileInput('<input type="month" ng-model="value" ng-model-options="{timezone: \'UTC\'}" />');

      $rootScope.$apply(function() {
        $rootScope.value = new Date(Date.UTC(2013, 7, 1, 1, 0, 0, 0));
      });
      helper.changeInputValueTo('2013-12');
      expect(+$rootScope.value).toBe(Date.UTC(2013, 11, 1, 1, 0, 0, 0));
      expect(inputElm.val()).toBe('2013-12');
    });

    it('should only change the month of a bound date in any timezone', function() {
      var inputElm = helper.compileInput('<input type="month" ng-model="value" ng-model-options="{timezone: \'+0500\'}" />');

      $rootScope.$apply(function() {
        $rootScope.value = new Date(Date.UTC(2013, 6, 31, 20, 0, 0));
      });
      helper.changeInputValueTo('2013-09');
      expect(+$rootScope.value).toBe(Date.UTC(2013, 7, 31, 20, 0, 0));
      expect(inputElm.val()).toBe('2013-09');
    });

    describe('min', function() {
      var inputElm;
      beforeEach(function() {
        $rootScope.minVal = '2013-01';
        inputElm = helper.compileInput('<input type="month" ng-model="value" name="alias" min="{{ minVal }}" />');
      });

      it('should invalidate', function() {
        helper.changeInputValueTo('2012-12');
        expect(inputElm).toBeInvalid();
        expect($rootScope.value).toBeFalsy();
        expect($rootScope.form.alias.$error.min).toBeTruthy();
      });

      it('should validate', function() {
        helper.changeInputValueTo('2013-07');
        expect(inputElm).toBeValid();
        expect(+$rootScope.value).toBe(+new Date(2013, 6, 1));
        expect($rootScope.form.alias.$error.min).toBeFalsy();
      });

      it('should revalidate when the min value changes', function() {

Review comment (bug):
Looking at this plnkr, http://plnkr.co/edit/TkRo7GD139Pab0qC5ZEm?p=preview it seems to be the case that there is no way to enter a year with more than 4 digits in Edge currently. In Chrome, I can always use the keyboard to input the parts of the date, and so I can also enter 5 digit dates. In Edge it looks like I can only select a date from the picker. Is this correct? This seems like a UX issue to me, and a bug in Edge.


Code after:
        var inputElm = helper.compileInput(
            '<input type="month" ng-model="value" ng-model-options="' + ngModelOptions + '" />');

        helper.changeInputValueTo('2013-07');
        expect(+$rootScope.value).toBe(Date.UTC(2013, 5, 30, 19, 0, 0));

        $rootScope.$apply(function() {
          $rootScope.value = new Date(Date.UTC(2014, 5, 30, 19, 0, 0));
        });
        expect(inputElm.val()).toBe('2014-07');
      }
    );


    it('should label parse errors as `month`', function() {
      var inputElm = helper.compileInput('<input type="month" ng-model="val" name="alias" />', {
        valid: false,
        badInput: true
      });

      helper.changeInputValueTo('xxx');
      expect(inputElm).toBeInvalid();
      expect($rootScope.form.alias.$error.month).toBeTruthy();
    });


    if (!isEdge) {
      it('should allow four or more digits in year', function() {
        var inputElm = helper.compileInput('<input type="month" ng-model="value"  ng-model-options="{timezone: \'UTC\'}"/>');

        helper.changeInputValueTo('10123-03');
        expect(+$rootScope.value).toBe(Date.UTC(10123, 2, 1, 0, 0, 0));

        $rootScope.$apply(function() {
          $rootScope.value = new Date(Date.UTC(20456, 3, 1, 0, 0, 0));
        });
        expect(inputElm.val()).toBe('20456-04');
      });
    }

    it('should only change the month of a bound date', function() {
      var inputElm = helper.compileInput('<input type="month" ng-model="value" ng-model-options="{timezone: \'UTC\'}" />');

      $rootScope.$apply(function() {
        $rootScope.value = new Date(Date.UTC(2013, 7, 1, 1, 0, 0, 0));
      });
      helper.changeInputValueTo('2013-12');
      expect(+$rootScope.value).toBe(Date.UTC(2013, 11, 1, 1, 0, 0, 0));
      expect(inputElm.val()).toBe('2013-12');
    });