ember-qunit
Advanced tools
Comparing version 0.1.5 to 0.1.6
@@ -43,2 +43,3 @@ "use strict"; | ||
setup: function(){ | ||
container = isolatedContainer(needs); | ||
dispatcher.setup(); | ||
@@ -45,0 +46,0 @@ Ember.$('<div id="ember-testing"/>').appendTo(document.body); |
{ | ||
"name": "ember-qunit", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"description": "unit test helpers for ember", | ||
"main": "dist/cjs/main.js", | ||
"scripts": { | ||
"test": "node_modules/.bin/bower install && rm -rf dist && node_modules/.bin/broccoli build dist && ./node_modules/.bin/karma start --browsers Firefox --single-run" | ||
"test": "bower install && rm -rf dist && broccoli build dist && karma start --browsers Firefox --single-run" | ||
}, | ||
@@ -9,0 +9,0 @@ "authors": [ |
139
README.md
@@ -0,2 +1,141 @@ | ||
Ember QUnit | ||
=========== | ||
[![Build Status](https://travis-ci.org/rpflorence/ember-qunit.png)](https://travis-ci.org/rpflorence/ember-qunit) | ||
[WIP] Unit test helpers for Ember. | ||
About | ||
----- | ||
Ember QUnit uses your application's resolver to find and automatically | ||
create test subjects for you with the `moduleFor` and `test` helpers. | ||
*This is a work in progress* but its also quite handy already. Feedback | ||
is highly encouraged. | ||
Module Formats | ||
-------------- | ||
You will find all the popular formats in `dist/`. If using globals, all | ||
methods are found on `window.emq`. | ||
Examples | ||
-------- | ||
### Global build setup: | ||
```js | ||
// inject test helpers onto window | ||
emq.globalize(); | ||
``` | ||
### Setting the resolver | ||
```js | ||
// if you don't have a custom resolver, do it like this: | ||
setResolver(Ember.DefaultResolver.create({namespace: App})); | ||
// otherwise something like: | ||
import Resolver from './path/to/resolver'; | ||
import {setResolver} from 'ember-qunit'; | ||
setResolver(Resolver.create()); | ||
``` | ||
### Simple example: | ||
```js | ||
// tell ember qunit what you are testing, it will find it from the | ||
// resolver | ||
moduleForComponent('x-foo', 'XFooComponent'); | ||
// run a test | ||
test('it renders', function() { | ||
expect(2); | ||
// creates the component instance | ||
var component = this.subject(); | ||
equal(component.state, 'preRender'); | ||
// appends the component to the page | ||
this.append(); | ||
equal(component.state, 'inDOM'); | ||
}); | ||
``` | ||
### Complex example | ||
```js | ||
// a more complex example taken from ic-tabs | ||
moduleForComponent('ic-tabs', 'TabsComponent', { | ||
// specify the other units that are required for this test | ||
needs: [ | ||
'component:ic-tab', | ||
'component:ic-tab-panel', | ||
'component:ic-tab-list' | ||
] | ||
}); | ||
test('selects first tab and shows the panel', function() { | ||
expect(3); | ||
var component = test.subject({ | ||
// can provide properties for the subject, like the yielded template | ||
// of a component (not the layout, in this case) | ||
template: Ember.Handlebars.compile(''+ | ||
'{{#ic-tab-list}}'+ | ||
'{{#ic-tab id="tab1"}}tab1{{/ic-tab}}'+ | ||
'{{#ic-tab id="tab2"}}tab2{{/ic-tab}}'+ | ||
'{{#ic-tab id="tab3"}}tab3{{/ic-tab}}'+ | ||
'{{/ic-tab-list}}'+ | ||
'{{#ic-tab-panel id="panel1"}}one{{/ic-tab-panel}}'+ | ||
'{{#ic-tab-panel id="panel2"}}two{{/ic-tab-panel}}'+ | ||
'{{#ic-tab-panel id="panel3"}}three{{/ic-tab-panel}}' | ||
}) | ||
}); | ||
this.append(); | ||
var tab1 = Ember.View.views['tab1']; | ||
var panel1 = Ember.View.views['panel1']; | ||
ok(component.get('activeTab') === tab1); | ||
ok(tab1.get('active')); | ||
var el = tab1.$(); | ||
ok(panel1.$().is(':visible')); | ||
}); | ||
``` | ||
Helpers | ||
------- | ||
### `moduleFor(fullName [, description [, callbacks]])` | ||
- `fullName`: (String) - The full name of the unit, ie | ||
`controller:application`, `route:index`. | ||
- `description`: (String) optional - The description of the module | ||
- `callbacks`: (Object) optional - Normal QUnit callbacks (setup and | ||
teardown), with addition to `needs`, which allows you specify the | ||
other units the tests will need. | ||
### `moduleForComponent(name, [description, callbacks])` | ||
- `name`: (String) - the short name of the component that you'd use in a | ||
template, ie `x-foo`, `ic-tabs`, etc. | ||
### `moduleForModel(name, [description, callbacks])` | ||
- `name`: (String) - the short name of the model you'd use in `store` | ||
operations ie `user`, `assignmentGroup`, etc. | ||
Contributing | ||
------------ | ||
```sh | ||
$ npm install | ||
$ bower install | ||
$ broccoli serve | ||
# new tab | ||
$ karma start | ||
``` | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
13279
195
142
0