Sha256: bcd64311923986fc946599cf6dd299227f7a92ce0261ff4b0987cd28045712d5

Contents?: true

Size: 1.87 KB

Versions: 3

Compression:

Stored size: 1.87 KB

Contents

import { EMBER_GLIMMER_ANGLE_BRACKET_INVOCATION } from '@ember/canary-features';
import { moduleFor, AbstractTestCase } from 'internal-test-helpers';
import { compile } from '../../index';

moduleFor(
  'ember-template-compiler: assert-splattribute-expression',
  class extends AbstractTestCase {
    expectedMessage(locInfo) {
      return EMBER_GLIMMER_ANGLE_BRACKET_INVOCATION
        ? `Using "...attributes" can only be used in the element position e.g. <div ...attributes />. It cannot be used as a path. (${locInfo}) `
        : `...attributes is an invalid path (${locInfo}) `;
    }

    '@test ...attributes is in element space'(assert) {
      if (EMBER_GLIMMER_ANGLE_BRACKET_INVOCATION) {
        assert.expect(0);

        compile('<div ...attributes>Foo</div>');
      } else {
        expectAssertion(() => {
          compile('<div ...attributes>Foo</div>');
        }, this.expectedMessage('L1:C5'));
      }
    }

    '@test {{...attributes}} is not valid'() {
      expectAssertion(() => {
        compile('<div>{{...attributes}}</div>', {
          moduleName: 'foo-bar',
        });
      }, this.expectedMessage(`'foo-bar' @ L1:C7`));
    }

    '@test {{...attributes}} is not valid path expression'() {
      expectAssertion(() => {
        compile('<div>{{...attributes}}</div>', {
          moduleName: 'foo-bar',
        });
      }, this.expectedMessage(`'foo-bar' @ L1:C7`));
    }
    '@test {{...attributes}} is not valid modifier'() {
      expectAssertion(() => {
        compile('<div {{...attributes}}>Wat</div>', {
          moduleName: 'foo-bar',
        });
      }, this.expectedMessage(`'foo-bar' @ L1:C7`));
    }

    '@test {{...attributes}} is not valid attribute'() {
      expectAssertion(() => {
        compile('<div class={{...attributes}}>Wat</div>', {
          moduleName: 'foo-bar',
        });
      }, this.expectedMessage(`'foo-bar' @ L1:C13`));
    }
  }
);

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
discourse-ember-source-3.6.0.0 dist/es/ember-template-compiler/tests/plugins/assert-splattribute-expression-test.js
discourse-ember-source-3.5.1.1 dist/es/ember-template-compiler/tests/plugins/assert-splattribute-expression-test.js
discourse-ember-source-3.5.1.0 dist/dist/es/ember-template-compiler/tests/plugins/assert-splattribute-expression-test.js