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'); + });