From eb233ddca136cdded85096af27bcc892b74de312 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Tue, 9 Jun 2015 14:31:09 -0800 Subject: [PATCH] Search button --- .../components/search-button/component.js | 13 +++++++++++++ .../components/search-button/template.hbs | 7 +++++++ .../search-button/component-test.js | 19 +++++++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 app/pods/components/search-button/component.js create mode 100644 app/pods/components/search-button/template.hbs create mode 100644 tests/unit/pods/components/search-button/component-test.js diff --git a/app/pods/components/search-button/component.js b/app/pods/components/search-button/component.js new file mode 100644 index 0000000..e37949d --- /dev/null +++ b/app/pods/components/search-button/component.js @@ -0,0 +1,13 @@ +import Ember from 'ember'; + +export default Ember.Component.extend({ + isLoading: false, + buttonText: 'Search', + actions: { + showLoading: function() { + if (!this.get('isLoading')) { + this.sendAction('action'); + } + } + } +}); diff --git a/app/pods/components/search-button/template.hbs b/app/pods/components/search-button/template.hbs new file mode 100644 index 0000000..4bd6134 --- /dev/null +++ b/app/pods/components/search-button/template.hbs @@ -0,0 +1,7 @@ + + {{#if isLoading}} + LOADING + {{else}} + {{buttonText}} + {{/if}} + diff --git a/tests/unit/pods/components/search-button/component-test.js b/tests/unit/pods/components/search-button/component-test.js new file mode 100644 index 0000000..6381186 --- /dev/null +++ b/tests/unit/pods/components/search-button/component-test.js @@ -0,0 +1,19 @@ +import { moduleForComponent, test } from 'ember-qunit'; + +moduleForComponent('search-button', 'Unit | Component | search button', { + // Specify the other units that are required for this test + // needs: ['component:foo', 'helper:bar'], + unit: true +}); + +test('it renders', function(assert) { + assert.expect(2); + + // Creates the component instance + var component = this.subject(); + assert.equal(component._state, 'preRender'); + + // Renders the component to the page + this.render(); + assert.equal(component._state, 'inDOM'); +});