Exemple #1
0
  ['@test getViewBounds on a regular component'](assert) {
    let component;
    this.registerComponent('hi-mom', {
      ComponentClass: Component.extend({
        init() {
          this._super(...arguments);
          component = this;
        }
      }),
      template: `<p>Hi, mom!</p>`
    });

    this.render(`{{hi-mom}}`);

    let { parentElement, firstNode, lastNode } = getViewBounds(component);

    assert.equal(parentElement, this.element, 'a regular component should have the right parentElement');
    assert.equal(firstNode, component.element, 'a regular component should have a single node that is its element');
    assert.equal(lastNode, component.element, 'a regular component should have a single node that is its element');
  }
Exemple #2
0
  ['@test getViewBounds on a tagless component'](assert) {
    let component;
    this.registerComponent('hi-mom', {
      ComponentClass: Component.extend({
        tagName: '',
        init() {
          this._super(...arguments);
          component = this;
        }
      }),
      template: `<span id="start-node">Hi,</span> <em id="before-end-node">mom</em>!`
    });

    this.render(`{{hi-mom}}`);

    let { parentElement, firstNode, lastNode } = getViewBounds(component);

    assert.equal(parentElement, this.element, 'a regular component should have the right parentElement');
    assert.equal(firstNode, this.$('#start-node')[0], 'a tagless component should have a range enclosing all of its nodes');
    assert.equal(lastNode, this.$('#before-end-node')[0].nextSibling, 'a tagless component should have a range enclosing all of its nodes');
  }