Skip to content

Commit

Permalink
Add test for boolean dynamicFn
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinpschaaf committed May 12, 2017
1 parent f197ce2 commit 03d21ce
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions test/unit/property-effects.html
Original file line number Diff line number Diff line change
Expand Up @@ -1621,27 +1621,33 @@
this.observer = sinon.spy();
}
}
TestClass.createMethodObserver('observer(a, b.c)');
TestClass.createMethodObserver('observer(a, b.c)', true);
customElements.define('pe-method-observer', TestClass);
let el = document.createElement('pe-method-observer');
document.body.appendChild(el);
assert.equal(el.observer.callCount, 0);
assert.equal(el.pcSpy.callCount, 0);
el.a = 'a';
assert.equal(el.observer.callCount, 1);
assert.deepEqual(el.observer.getCall(0).args, ['a', undefined]);
assert.deepEqual(el.observer.getCall(0).args, [undefined, undefined]);
assert.equal(el.pcSpy.callCount, 1);
el.b = {c: 'c'};
el.a = 'a';
assert.equal(el.observer.callCount, 2);
assert.deepEqual(el.observer.getCall(1).args, ['a', 'c']);
assert.deepEqual(el.observer.getCall(1).args, ['a', undefined]);
assert.equal(el.pcSpy.callCount, 2);
el.b = {c: 'c'};
assert.equal(el.observer.callCount, 3);
assert.deepEqual(el.observer.getCall(2).args, ['a', 'c']);
assert.equal(el.pcSpy.callCount, 3);
el.setProperties({
a: 'A',
b: {c: 'C'}
})
assert.equal(el.observer.callCount, 3);
assert.deepEqual(el.observer.getCall(2).args, ['A', 'C']);
assert.equal(el.pcSpy.callCount, 3);
assert.equal(el.observer.callCount, 4);
assert.deepEqual(el.observer.getCall(3).args, ['A', 'C']);
assert.equal(el.pcSpy.callCount, 4);

el.observer = sinon.spy();
assert.equal(el.observer.callCount, 1);
assert.deepEqual(el.observer.getCall(0).args, ['A', 'C']);
assert.equal(el.pcSpy.callCount, 5);
document.body.removeChild(el);
});

Expand Down

0 comments on commit 03d21ce

Please sign in to comment.