From 0f538653a03daf9f18f94e584bd3b6676ac98677 Mon Sep 17 00:00:00 2001 From: Casey Watts Date: Thu, 30 Nov 2017 16:30:19 -0500 Subject: [PATCH 1/4] pass through options to addToHomescreen() --- addon/components/add-to-homescreen.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addon/components/add-to-homescreen.js b/addon/components/add-to-homescreen.js index 7e99ca55..93a5f351 100644 --- a/addon/components/add-to-homescreen.js +++ b/addon/components/add-to-homescreen.js @@ -8,6 +8,7 @@ export default Component.extend({ didInsertElement() { this._super(...arguments); - window.addToHomescreen({ debug: false }); + const config = Object.assign({debug: false}, this.get('attrs')); + window.addToHomescreen(config); } }); From 7d714e8c4299727095c9b682f474af64442034d6 Mon Sep 17 00:00:00 2001 From: Casey Watts Date: Thu, 30 Nov 2017 16:58:15 -0500 Subject: [PATCH 2/4] now that we're using attrs, we have to use the didReceiveAttr hook --- addon/components/add-to-homescreen.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addon/components/add-to-homescreen.js b/addon/components/add-to-homescreen.js index 93a5f351..6581c3c7 100644 --- a/addon/components/add-to-homescreen.js +++ b/addon/components/add-to-homescreen.js @@ -6,7 +6,7 @@ const { Component } = Ember; export default Component.extend({ layout, - didInsertElement() { + didReceiveAttr() { this._super(...arguments); const config = Object.assign({debug: false}, this.get('attrs')); window.addToHomescreen(config); From 6dd353b4a06a5b68d22e6dc4514039b8d264b367 Mon Sep 17 00:00:00 2001 From: Casey Watts Date: Thu, 30 Nov 2017 16:59:43 -0500 Subject: [PATCH 3/4] refactor tests to have their own blocks --- tests/integration/components/add-to-homescreen-test.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tests/integration/components/add-to-homescreen-test.js b/tests/integration/components/add-to-homescreen-test.js index d9f62d01..8f080d3d 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 From f6f41bad978aa0602c7d8abb24c128609db8770d Mon Sep 17 00:00:00 2001 From: Casey Watts Date: Thu, 30 Nov 2017 17:04:20 -0500 Subject: [PATCH 4/4] add a (failing) test that arguments can be passed to add-to-homescreen --- tests/integration/components/add-to-homescreen-test.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/integration/components/add-to-homescreen-test.js b/tests/integration/components/add-to-homescreen-test.js index 8f080d3d..edeb0d1f 100644 --- a/tests/integration/components/add-to-homescreen-test.js +++ b/tests/integration/components/add-to-homescreen-test.js @@ -20,3 +20,11 @@ test('it renders in block form', 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'); +});