diff --git a/addon/components/add-to-homescreen.js b/addon/components/add-to-homescreen.js index 7e99ca55..6581c3c7 100644 --- a/addon/components/add-to-homescreen.js +++ b/addon/components/add-to-homescreen.js @@ -6,8 +6,9 @@ const { Component } = Ember; export default Component.extend({ layout, - didInsertElement() { + didReceiveAttr() { this._super(...arguments); - window.addToHomescreen({ debug: false }); + const config = Object.assign({debug: false}, this.get('attrs')); + window.addToHomescreen(config); } }); diff --git a/tests/integration/components/add-to-homescreen-test.js b/tests/integration/components/add-to-homescreen-test.js index d9f62d01..edeb0d1f 100644 --- a/tests/integration/components/add-to-homescreen-test.js +++ b/tests/integration/components/add-to-homescreen-test.js @@ -6,16 +6,12 @@ moduleForComponent('add-to-homescreen', 'Integration | Component | add to homesc }); test('it renders', function(assert) { - assert.expect(2); - - // Set any properties with this.set('myProperty', 'value'); - // Handle any actions with this.on('myAction', function(val) { ... }); - this.render(hbs`{{add-to-homescreen}}`); assert.equal(this.$().text().trim(), ''); +}); - // Template block usage: +test('it renders in block form', function(assert) { this.render(hbs` {{#add-to-homescreen}} template block text @@ -24,3 +20,11 @@ test('it renders', function(assert) { assert.equal(this.$().text().trim(), 'template block text'); }); + +test('it renders with arguments passed', function(assert) { + this.render(hbs` + {{add-to-homescreen message="text passed into the message attr"}} + `); + + assert.equal(this.$().text().trim(), 'text passed into the message attr'); +});