diff --git a/addon/utils/bind-data-test-attributes.js b/addon/utils/bind-data-test-attributes.js index 3996702c..09f8cb9f 100644 --- a/addon/utils/bind-data-test-attributes.js +++ b/addon/utils/bind-data-test-attributes.js @@ -15,6 +15,10 @@ export default function bindDataTestAttributes(component) { let attributeBindings = component.getWithDefault('attributeBindings', []); + if (!Ember.isArray(attributeBindings)) { + attributeBindings = [attributeBindings]; + } + for (let attr in component) { if (TEST_SELECTOR_PREFIX.test(attr)) { attributeBindings.push(attr); diff --git a/tests/unit/utils/bind-data-test-attributes-test.js b/tests/unit/utils/bind-data-test-attributes-test.js index b468934a..284963ff 100644 --- a/tests/unit/utils/bind-data-test-attributes-test.js +++ b/tests/unit/utils/bind-data-test-attributes-test.js @@ -42,6 +42,26 @@ test('it adds to existing attributeBindings array', function(assert) { ['foo', 'bar', 'data-test-from-invocation', 'data-test-from-factory']); }); +test('it converts existing attributeBindings string to array', function(assert) { + let Fixture = Ember.Object.extend({ + attributeBindings: 'foo', + + foo: 1, + + 'data-test-from-factory': 'foo', + }); + let instance = Fixture.create({ + 'data-test-from-invocation': 'bar', + }); + + assert.deepEqual(instance.get('attributeBindings'), 'foo'); + + bindDataTestAttributes(instance); + + assert.deepEqual(instance.get('attributeBindings'), + ['foo', 'data-test-from-invocation', 'data-test-from-factory']); +}); + test('it only adds data-test-* properties', function(assert) { let Fixture = Ember.Object.extend({ foo: 1,