Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Got the nav-menu-test running #150

Merged
merged 1 commit into from
Jul 24, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
@@ -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

43 changes: 31 additions & 12 deletions tests/unit/components/nav-menu-test.js
Original file line number Diff line number Diff line change
@@ -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');

});