Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
remove tests for undefined paths
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelw committed Dec 6, 2013
1 parent c141037 commit 48e9efe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/observe.js
Original file line number Diff line number Diff line change
Expand Up @@ -665,8 +665,8 @@
function PathObserver(object, path, callback, target, transformFn,
setValueFn) {
var path = path instanceof Path ? path : getPath(path);
if (!path || !path.length || !isObject(object)) {
this.value_ = path ? path.getValueFrom(object) : undefined;
if (!path.valid || !path.length || !isObject(object)) {
this.value_ = path.getValueFrom(object);
this.value = transformFn ? transformFn(this.value_) : this.value_;
this.closed_ = true;
return;
Expand Down Expand Up @@ -768,7 +768,7 @@
throw Error('Cannot add more paths once started.');

var path = path instanceof Path ? path : getPath(path);
var value = path ? path.getValueFrom(object) : undefined;
var value = path.getValueFrom(object);

this.observed_.push(object, path);
this.values_.push(value);
Expand All @@ -787,8 +787,6 @@
var anyChanged = false;
for (var i = 0; i < this.observed_.length; i = i+2) {
var path = this.observed_[i+1];
if (!path)
continue;
var object = this.observed_[i];
var value = path.getValueFrom(object, this.observedSet_);
var oldValue = this.values_[i/2];
Expand Down
7 changes: 7 additions & 0 deletions tests/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,13 @@ suite('PathObserver Tests', function() {

teardown(doTeardown);

test('invalid', function() {
var observer = new PathObserver({ a: { b: 1 }} , 'a b', callback);
assert.strictEqual(undefined, observer.value);
observer.deliver();
assert.isFalse(callbackInvoked);
});

test('Close Invokes Close', function() {
var called = false;
var obj = { foo: 1, close: function() { called = true }};
Expand Down

0 comments on commit 48e9efe

Please sign in to comment.