Skip to content
Permalink
Browse files

feat(observable): add propertyName argument

  • Loading branch information...
RobertHerhold authored and jdanyow committed Sep 2, 2016
1 parent 044746f commit e7825eb95f028e16dd55512056118f02c20f41d1
Showing with 8 additions and 8 deletions.
  1. +1 −1 src/decorator-observable.js
  2. +7 −7 test/decorator-observable.spec.js
@@ -34,7 +34,7 @@ export function observable(targetOrConfig: any, key: string, descriptor?: Proper
let oldValue = this[innerPropertyName];
this[innerPropertyName] = newValue;
if (this[callbackName]) {
this[callbackName](newValue, oldValue);
this[callbackName](newValue, oldValue, key);
}
};

@@ -14,7 +14,7 @@ describe('observable decorator', () => {
spyOn(instance, 'valueChanged');

instance.value = newValue;
expect(instance.valueChanged).toHaveBeenCalledWith(newValue, oldValue);
expect(instance.valueChanged).toHaveBeenCalledWith(newValue, oldValue, 'value');
});

it('should call valueChanged when changing the undefined property', () => {
@@ -25,7 +25,7 @@ describe('observable decorator', () => {
spyOn(instance, 'valueChanged');

instance.value = newValue;
expect(instance.valueChanged).toHaveBeenCalledWith(newValue, undefined);
expect(instance.valueChanged).toHaveBeenCalledWith(newValue, undefined, 'value');
});

it('should call customHandler when changing the property', () => {
@@ -36,7 +36,7 @@ describe('observable decorator', () => {
spyOn(instance, 'customHandler');

instance.value = newValue;
expect(instance.customHandler).toHaveBeenCalledWith(newValue, oldValue);
expect(instance.customHandler).toHaveBeenCalledWith(newValue, oldValue, 'value');
});

it('should call customHandler when changing the undefined property', () => {
@@ -47,7 +47,7 @@ describe('observable decorator', () => {
spyOn(instance, 'customHandler');

instance.value = newValue;
expect(instance.customHandler).toHaveBeenCalledWith(newValue, undefined);
expect(instance.customHandler).toHaveBeenCalledWith(newValue, undefined, 'value');
});

it('should work when valueChanged is undefined', () => {
@@ -81,7 +81,7 @@ describe('observable decorator', () => {
spyOn(instance, 'valueChanged');

instance.value = newValue;
expect(instance.valueChanged).toHaveBeenCalledWith(newValue, oldValue);
expect(instance.valueChanged).toHaveBeenCalledWith(newValue, oldValue, 'value');
});

it('should work with decorators function when property is undefined', () => {
@@ -92,7 +92,7 @@ describe('observable decorator', () => {
spyOn(instance, 'valueChanged');

instance.value = newValue;
expect(instance.valueChanged).toHaveBeenCalledWith(newValue, undefined);
expect(instance.valueChanged).toHaveBeenCalledWith(newValue, undefined, 'value');
});

it('should work with decorators function and config', () => {
@@ -106,6 +106,6 @@ describe('observable decorator', () => {
spyOn(instance, 'customHandler');

instance.value = newValue;
expect(instance.customHandler).toHaveBeenCalledWith(newValue, oldValue);
expect(instance.customHandler).toHaveBeenCalledWith(newValue, oldValue, 'value');
});
});

0 comments on commit e7825eb

Please sign in to comment.
You can’t perform that action at this time.