|
633 | 633 |
|
634 | 634 | });
|
635 | 635 |
|
| 636 | +suite('handling notifying evevnts', function() { |
| 637 | + |
| 638 | + test('handle notifcation event and set property with observer when connected', function() { |
| 639 | + var el = document.createElement('x-handle-notify-event'); |
| 640 | + document.body.appendChild(el); |
| 641 | + assert.ok(el.shadowRoot.querySelector('#before'), 'element not found before default notifying elmeent'); |
| 642 | + assert.ok(el.shadowRoot.querySelector('#later'), 'element not found after default notifying elmeent'); |
| 643 | + assert.isTrue(el.readySpy.calledOnce, 'ready called more than once'); |
| 644 | + assert.isTrue(el.handleNotify.calledOnce, 'listener called more than once'); |
| 645 | + assert.isTrue(el.propChanged.calledOnce, 'observer called more than once'); |
| 646 | + assert.isTrue(el.handleNotify.calledBefore(el.propChanged), 'observer called before event'); |
| 647 | + assert.isTrue(el.afterSettingProp.calledBefore(el.propChanged), 'accessor side effect processed during notifying event (before clients ready)'); |
| 648 | + assert.isTrue(el.propChanged.calledBefore(el.readySpy), 'observer called before ready'); |
| 649 | + document.body.removeChild(el); |
| 650 | + }); |
| 651 | + |
| 652 | + test('handle notifcation event and set property with observer when *not* connected and _enableProperties called', function() { |
| 653 | + var el = document.createElement('x-handle-notify-event'); |
| 654 | + el._enableProperties(); |
| 655 | + assert.ok(el.shadowRoot.querySelector('#before'), 'element not found before default notifying elmeent'); |
| 656 | + assert.ok(el.shadowRoot.querySelector('#later'), 'element not found after default notifying elmeent'); |
| 657 | + assert.isTrue(el.readySpy.calledOnce, 'ready called more than once'); |
| 658 | + assert.isTrue(el.handleNotify.calledOnce, 'listener called more than once'); |
| 659 | + assert.isTrue(el.propChanged.calledOnce, 'observer called more than once'); |
| 660 | + assert.isTrue(el.handleNotify.calledBefore(el.propChanged), 'observer called before event'); |
| 661 | + assert.isTrue(el.afterSettingProp.calledBefore(el.propChanged), 'accessor side effect processed during notifying event (before clients ready)'); |
| 662 | + assert.isTrue(el.propChanged.calledBefore(el.readySpy), 'observer called before ready'); |
| 663 | + }); |
| 664 | + |
| 665 | +}); |
| 666 | + |
636 | 667 | suite('1-way binding effects between elements', function() {
|
637 | 668 |
|
638 | 669 | var el;
|
|
0 commit comments