From 0ae903f9f15794f4c4c221472c9c96ccc2d0c772 Mon Sep 17 00:00:00 2001 From: Alex Houchens Date: Wed, 6 May 2015 14:17:12 -0700 Subject: [PATCH] Add tests for bonfire config concerning appName Closes bonfirejs/bf-header#5 --- addon/components/bf-header.js | 4 ++-- tests/dummy/config/environment.js | 3 +++ tests/unit/components/bf-header-test.js | 16 +++++++--------- tests/unit/initializers/bf-header-test.js | 23 ----------------------- 4 files changed, 12 insertions(+), 34 deletions(-) delete mode 100644 tests/unit/initializers/bf-header-test.js diff --git a/addon/components/bf-header.js b/addon/components/bf-header.js index 5c54de5..8b1bb43 100644 --- a/addon/components/bf-header.js +++ b/addon/components/bf-header.js @@ -28,12 +28,12 @@ export default Ember.Component.extend({ @default application.namespace.name @return {String} Application name */ - appName: function() { + appName: Ember.computed(function() { var ENV = this.container.lookupFactory('config:environment'); if (ENV.APP && ENV.APP.bonfire && ENV.APP.bonfire.title) { return ENV.APP.bonfire.title; } else { return Ember.String.capitalize(ENV.APP.name); } - }.property() + }) }); diff --git a/tests/dummy/config/environment.js b/tests/dummy/config/environment.js index c59bcd5..8ba1ead 100644 --- a/tests/dummy/config/environment.js +++ b/tests/dummy/config/environment.js @@ -16,6 +16,9 @@ module.exports = function(environment) { APP: { // Here you can pass flags/options to your application instance // when it is created + bonfire: { + title: "Testing bf-header" + } } }; diff --git a/tests/unit/components/bf-header-test.js b/tests/unit/components/bf-header-test.js index 959cae8..70c2f1b 100644 --- a/tests/unit/components/bf-header-test.js +++ b/tests/unit/components/bf-header-test.js @@ -3,19 +3,17 @@ import { test } from 'ember-qunit'; +import ENV from "dummy/config/environment"; + moduleForComponent('bf-header', { // specify the other units that are required for this test // needs: ['component:foo', 'helper:bar'] }); -test('it renders', function(assert) { - assert.expect(2); - - // creates the component instance - var component = this.subject(); - assert.equal(component._state, 'preRender'); +test('check if bonfire is in config', function(assert) { + assert.equal(Object.hasOwnProperty.call(ENV.APP, 'bonfire'), true); +}); - // renders the component to the page - this.render(); - assert.equal(component._state, 'inDOM'); +test('check if bonfire title is in config', function(assert) { + assert.equal(Object.hasOwnProperty.call(ENV.APP.bonfire, 'title'), true); }); diff --git a/tests/unit/initializers/bf-header-test.js b/tests/unit/initializers/bf-header-test.js deleted file mode 100644 index c88d206..0000000 --- a/tests/unit/initializers/bf-header-test.js +++ /dev/null @@ -1,23 +0,0 @@ -import Ember from 'ember'; -import { initialize } from '../../../initializers/bf-header'; -import { module, test } from 'qunit'; - -var container, application; - -module('BfHeaderInitializer', { - beforeEach: function() { - Ember.run(function() { - application = Ember.Application.create(); - container = application.__container__; - application.deferReadiness(); - }); - } -}); - -// Replace this with your real tests. -test('it works', function(assert) { - initialize(container, application); - - // you would normally confirm the results of the initializer here - assert.ok(true); -});