mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 01:13:23 -04:00
add test for nested watchers
This commit is contained in:
parent
f50ba1cd48
commit
1baad7f962
1 changed files with 29 additions and 0 deletions
|
@ -1,4 +1,5 @@
|
|||
define(function (require) {
|
||||
var _ = require('lodash');
|
||||
describe('$scope.$watchMulti', function () {
|
||||
var sinon = require('test_utils/auto_release_sinon');
|
||||
|
||||
|
@ -167,5 +168,33 @@ define(function (require) {
|
|||
expect(stub.firstCall.args[1]).to.eql([firstValue, secondValue]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('nested watchers', function () {
|
||||
it('should trigger the handler at least once', function () {
|
||||
var $scope = $rootScope.$new();
|
||||
$scope.$$watchers = [{
|
||||
get: _.noop,
|
||||
fn: _.noop,
|
||||
eq: false,
|
||||
last: false
|
||||
}, {
|
||||
get: _.noop,
|
||||
fn: registerWatchers,
|
||||
eq: false,
|
||||
last: false
|
||||
}];
|
||||
|
||||
var first = sinon.stub();
|
||||
var second = sinon.stub();
|
||||
|
||||
function registerWatchers() {
|
||||
$scope.$watchMulti([first, second], function () {
|
||||
expect(first.callCount).to.be.greaterThan(0);
|
||||
expect(second.callCount).to.be.greaterThan(0);
|
||||
});
|
||||
}
|
||||
$scope.$digest();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue