From a2c212c9faf4a67713f07c8abc6517a38cd3a246 Mon Sep 17 00:00:00 2001 From: Nate Good Date: Wed, 22 Jul 2015 23:28:01 -0400 Subject: [PATCH] Got the nav test running by providing some subnav items required to execute the init method. Useful tests and assertions to follow. --- tests/README.md | 12 +++++++ tests/unit/components/nav-menu-test.js | 43 +++++++++++++++++++------- 2 files changed, 43 insertions(+), 12 deletions(-) create mode 100644 tests/README.md diff --git a/tests/README.md b/tests/README.md new file mode 100644 index 0000000000..19ab5f5b01 --- /dev/null +++ b/tests/README.md @@ -0,0 +1,12 @@ +### How to write Unit tests in Ember +TODO + +### How Hospital Run implements unit tests +TODO + +### How to run unit tests +* Run the ember test server: `ember test --server` + - This will monitor for changes to the source or the test and run them automatically. +* Hint: Add `&nocontainer=hidden` to testem results viewer to get rid of nasty white div: +http://localhost:7357/8986/tests/index.html?module=NavMenuComponent&nojshint=true&nocontainer=hidden + diff --git a/tests/unit/components/nav-menu-test.js b/tests/unit/components/nav-menu-test.js index e72145376b..5e4eada69f 100644 --- a/tests/unit/components/nav-menu-test.js +++ b/tests/unit/components/nav-menu-test.js @@ -1,21 +1,40 @@ import { - moduleForComponent, - test -} from 'ember-qunit'; + test, moduleForComponent +} +from 'ember-qunit'; +import startApp from '../../helpers/start-app'; -moduleForComponent('nav-menu', 'NavMenuComponent', { - // specify the other units that are required for this test - // needs: ['component:foo', 'helper:bar'] -}); +moduleForComponent('nav-menu', 'NavMenuComponent', {}); + +test('it renders', function(assert) { -test('it renders', function() { expect(2); + var startingMenu = { + title: 'Inventory', + iconClass: 'octicon-package', + route: 'inventory', + capability: 'inventory', + subnav: [{ + title: 'Requests', + iconClass: 'octicon-chevron-right', + route: 'inventory.index', + capability: 'add_inventory_request' + }, { + title: 'Items', + iconClass: 'octicon-chevron-right', + route: 'inventory.listing', + capability: 'inventory' + }] + }; + // creates the component instance - var component = this.subject(); - equal(component._state, 'preRender'); + var navMenuProperties = { nav: startingMenu }; + var navMenu = this.subject( navMenuProperties ); + equal(navMenu._state, 'preRender'); - // appends the component to the page + // appends the navMenu to the page this.append(); - equal(component._state, 'inDOM'); + equal(navMenu._state, 'inDOM'); + });