/
githubmirror
/
angular.js
Обзор
Документация
Войти
/
githubmirror
/
angular.js
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
test/ng/directive/ngChangeSpec.js
54 строки
2 KB
Lucas Mirelmann
chore(*): Upgrade to Jasmine 2.4
16 мар 2016, 12:15
16 мар 2016, 12:15
eb16611
Код
Авторство
О чём код?
'use strict'; /* globals generateInputCompilerHelper: false */ describe('ngChange', function() { var helper = {}, $rootScope; generateInputCompilerHelper(helper); beforeEach(inject(function(_$rootScope_) { $rootScope = _$rootScope_; })); it('should $eval expression after new value is set in the model', function() { helper.compileInput('<input type="text" ng-model="value" ng-change="change()" />'); $rootScope.change = jasmine.createSpy('change').and.callFake(function() { expect($rootScope.value).toBe('new value'); }); helper.changeInputValueTo('new value'); expect($rootScope.change).toHaveBeenCalledOnce(); }); it('should not $eval the expression if changed from model', function() { helper.compileInput('<input type="text" ng-model="value" ng-change="change()" />'); $rootScope.change = jasmine.createSpy('change'); $rootScope.$apply('value = true'); expect($rootScope.change).not.toHaveBeenCalled(); }); it('should $eval ngChange expression on checkbox', function() { var inputElm = helper.compileInput('<input type="checkbox" ng-model="foo" ng-change="changeFn()">'); $rootScope.changeFn = jasmine.createSpy('changeFn'); expect($rootScope.changeFn).not.toHaveBeenCalled(); browserTrigger(inputElm, 'click'); expect($rootScope.changeFn).toHaveBeenCalledOnce(); }); it('should be able to change the model and via that also update the view', function() { var inputElm = helper.compileInput('<input type="text" ng-model="value" ng-change="value=\'b\'" />'); helper.changeInputValueTo('a'); expect(inputElm.val()).toBe('b'); }); });