forked from knockout/knockout
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextenderBehaviors.js
23 lines (19 loc) · 914 Bytes
/
extenderBehaviors.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
describe('Extenders', function() {
it('Should be able to extend any subscribable', function () {
ko.extenders.setDummyProperty = function(target, value) {
target.dummyProperty = value;
};
var subscribable = new ko.subscribable();
expect(subscribable.dummyProperty).toEqual(undefined);
subscribable.extend({ setDummyProperty : 123 });
expect(subscribable.dummyProperty).toEqual(123);
});
it('Should be able to chain extenders', function() {
ko.extenders.wrapInParentObject = function(target, value) {
return { inner : target, extend : target.extend }
};
var underlyingSubscribable = new ko.subscribable();
var result = underlyingSubscribable.extend({ wrapInParentObject:true }).extend({ wrapInParentObject:true });
expect(result.inner.inner).toEqual(underlyingSubscribable);
});
});