feat(ngModelController): add $setDirty method

- extract existing functionality to public method: $setDirty
- add tests to corresponding changes
- refactor code to use extracted method

Closes #10038
Closes #10049
This commit is contained in:
IShotTheSheriff
2014-11-13 22:44:17 +01:00
committed by Martin Staffa
parent bb16759f0b
commit e8941c0fe5
2 changed files with 37 additions and 5 deletions

View File

@@ -139,6 +139,23 @@ describe('NgModelController', function() {
});
});
describe('setDirty', function() {
it('should set control to its dirty state', function() {
expect(ctrl.$pristine).toBe(true);
expect(ctrl.$dirty).toBe(false);
ctrl.$setDirty();
expect(ctrl.$pristine).toBe(false);
expect(ctrl.$dirty).toBe(true);
});
it('should set parent form to its dirty state', function() {
ctrl.$setDirty();
expect(parentFormCtrl.$setDirty).toHaveBeenCalled();
});
});
describe('setUntouched', function() {
it('should set control to its untouched state', function() {