Disable ready event or dom change event in a WCT test?

113 views Asked by At

In polymer 1.*, I am writing a test. My original element has a ready handler which acts on dom-change.

WCT does not provide a way to stub anything in the ready handler. It also does not allow me to stub data on the host property at the time exact time the element is stamped, which the ready handler instantly uses.

Once the element is stamped in the test, anything in the ready handler invokes.

To work around this, I am trying suppress dom change event in the but it not effective.

Any ideas how I can stop the ready handler from invoking in the test?

Original code:

    _setAnswers: function(answers) {
      var radioGroups =
        Polymer.dom(this.root).querySelectorAll('paper-radio-group');

      var radioGroupsArray = Array.prototype.slice.call(radioGroups);

      answers.forEach(this._setAnswer.bind(this, radioGroupsArray));
    },

    _setRadioDefaults: function() {
      this._setAnswers(this.answers.answers);
      this._setParentFieldAnswer(this.answers.answers[0].value);
    },

    ready: function() {
      this.$$('#fields').addEventListener('dom-change',
      this._setRadioDefaults.bind(this), {once: true});
    },

original test:

<test-fixture id="sp-non-cash-benefits-form-edit">
  <template>
    <h2>sp non cash benefits edit form</h2>
      <sp-non-cash-benefits-form-edit></sp-non-cash-benefits-form-edit>
  </template>
</test-fixture>

test where dom changed is disabled

 'sp-static-forms/sp-non-cash-benefits/sp-non-cash-benefits-form-edit.html?dom=shady&suppressDomChange=true',
0

There are 0 answers