diff --git a/tests/integration/bind-data-test-attributes-test.js b/tests/integration/bind-data-test-attributes-test.js deleted file mode 100644 index ac4f15f1..00000000 --- a/tests/integration/bind-data-test-attributes-test.js +++ /dev/null @@ -1,34 +0,0 @@ -import { moduleForComponent, test } from 'ember-qunit'; -import hbs from 'htmlbars-inline-precompile'; -import config from 'dummy/config/environment'; - -moduleForComponent( - 'print-test-attributes', - 'StripTestSelectorsTransform plugin', - { - integration: true - } -); - -if (!config.stripTestSelectors) { - test('It throws an error when a data-test-attribute is added on a tagless component', function(assert) { - assert.expect(1); - try { - this.render( - hbs`{{data-test-component tagName='' data-test-attribute=true}}` - ); - assert.ok(false, 'this should not be called'); - } catch (e) { - assert.ok(true, 'this is called'); - } - }); -} else { - test('it doest not throw an error when stripTestSelectors is set to true in the config', function(assert) { - this.render( - hbs`{{data-test-component tagName='' data-test-attribute=true}}` - ); - assert - .dom('[data-test-attribute]') - .doesNotExist('data-test-attribute was stripped, so no error is thrown'); - }); -} diff --git a/tests/unit/utils/bind-data-test-attributes-test.js b/tests/unit/utils/bind-data-test-attributes-test.js index d32e7d86..f6f04f4d 100644 --- a/tests/unit/utils/bind-data-test-attributes-test.js +++ b/tests/unit/utils/bind-data-test-attributes-test.js @@ -1,5 +1,6 @@ import { module, test } from 'qunit'; import EmberObject, { computed } from '@ember/object'; +import config from 'dummy/config/environment'; import bindDataTestAttributes from 'ember-test-selectors/utils/bind-data-test-attributes'; @@ -118,3 +119,30 @@ test('it skips if attributeBindings is a computed property', function(assert) { assert.deepEqual(instance.get('attributeBindings'), ['foo']); }); + +if (!config.stripTestSelectors) { + test('it breaks if tagName is empty', function(assert) { + let Fixture = EmberObject.extend({ + tagName: '', + 'data-test-from-factory': 'foo', + }); + let instance = Fixture.create({ + 'data-test-from-invocation': 'bar', + }); + + assert.throws(() => bindDataTestAttributes(instance)); + }); +} else { + test('it does not break if tagName is empty and selectors are stripped', function(assert) { + let Fixture = EmberObject.extend({ + tagName: '', + 'data-test-from-factory': 'foo', + }); + let instance = Fixture.create({ + 'data-test-from-invocation': 'bar', + }); + + bindDataTestAttributes(instance); + assert.ok(true); + }); +}