Skip to content

Commit

Permalink
Merge pull request emberjs#99 from dgeb/separate-test-helpers
Browse files Browse the repository at this point in the history
Refactor to use the extracted lib ember-test-helpers
  • Loading branch information
rwjblue committed Oct 28, 2014
2 parents f3f8527 + 89ea8e2 commit 778f806
Show file tree
Hide file tree
Showing 47 changed files with 515 additions and 1,860 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
tmp
node_modules
bower_components

tmp
dist
build
7 changes: 2 additions & 5 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
bower_components
dist/amd
dist/named-amd
dist/globals
lib
test
tests
.travis.yml
bower.json
Brocfile.js
karma.conf.js
testem.json
tmp
14 changes: 8 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
language: node_js
node_js:
- "0.11"
- "0.10"
before_script:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start

install:
- npm install -g bower broccoli-cli
- npm install
- bower install

script:
- npm test
82 changes: 73 additions & 9 deletions Brocfile.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,76 @@
var makeModules = require('broccoli-dist-es6-module');
var concat = require('broccoli-concat');
var pickFiles = require('broccoli-static-compiler');
var mergeTrees = require('broccoli-merge-trees');
var compileES6 = require('broccoli-es6-concatenator');

module.exports = makeModules('lib', {
global: 'emq',
packageName: 'ember-qunit',
main: 'main',
shim: {
'ember': 'Ember',
'qunit': 'QUnit'
}
// --- Compile ES6 modules ---

var loader = pickFiles('bower_components', {
srcDir: 'loader',
files: ['loader.js'],
destDir: '/'
});

// TODO - this manual dependency management has got to go!
var klassy = pickFiles('bower_components', {
srcDir: '/klassy/lib',
files: ['klassy.js'],
destDir: '/'
});
var emberTestHelpers = pickFiles('bower_components', {
srcDir: '/ember-test-helpers/lib',
files: ['**/*.js'],
destDir: '/'
});
var deps = mergeTrees([klassy, emberTestHelpers]);

var lib = pickFiles('lib', {
srcDir: '/',
files: ['**/*.js'],
destDir: '/'
});

var tests = pickFiles('tests', {
srcDir: '/',
files: ['test-support/*.js', '*.js'],
destDir: '/tests'
});

var main = mergeTrees([loader, deps, lib, tests]);
main = compileES6(main, {
loaderFile: '/loader.js',
inputFiles: ['**/*.js'],
ignoredModules: ['ember'],
outputFile: '/assets/ember-qunit-tests.amd.js'
});

// --- Select and concat vendor / support files ---

var vendor = concat('bower_components', {
inputFiles: ['jquery/dist/jquery.js',
'handlebars/handlebars.js',
'ember/ember.js',
'ember-data/ember-data.js'],
outputFile: '/assets/vendor.js'
});

var qunit = pickFiles('bower_components', {
srcDir: '/qunit/qunit',
files: ['qunit.js', 'qunit.css'],
destDir: '/assets'
});

var testIndex = pickFiles('tests', {
srcDir: '/',
files: ['index.html'],
destDir: '/tests'
});

var testSupport = concat('bower_components', {
inputFiles: ['ember-cli-shims/app-shims.js',
'ember-cli-test-loader/test-loader.js'],
outputFile: '/assets/test-support.js'
});

module.exports = mergeTrees([main, vendor, testIndex, qunit, testSupport]);

77 changes: 36 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,10 @@
Ember QUnit
===========
# Ember QUnit [![Build Status](https://travis-ci.org/rjackson/ember-qunit.png)](https://travis-ci.org/rwjblue/ember-qunit)

[![Build Status](https://travis-ci.org/rjackson/ember-qunit.png)](https://travis-ci.org/rwjblue/ember-qunit)
Ember QUnit simplifies unit testing of Ember applications with QUnit by
providing QUnit-specific wrappers around the helpers contained in
[ember-test-helpers](https://github.com/switchfly/ember-test-helpers).

[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.

Simple Usage
------------

Include `dist/globals/main.js` as a script in your tests index.html

Module Formats
--------------

You will find all the popular formats in `dist/`. If using globals, all
methods are found on `window.emq`.

Examples
--------
## Usage

### Global build setup:

Expand Down Expand Up @@ -108,7 +86,7 @@ test('selects first tab and shows the panel', function() {
ok(panel1.$().is(':visible'));
});
```
If you are using nested components with templates, you have to list them separately - otherwise your templates won't be loaded:
If you are using nested components with templates, you have to list them separately - otherwise your templates won't be loaded:
```js
moduleForComponent('ic-tabs', 'TabsComponent', {

Expand Down Expand Up @@ -155,7 +133,7 @@ the error and assert that you got there:
test('sometimes async gets rejected', function(){
expect(1);
var myThing = MyThing.create()

return myThing.exampleMethod().then(function(){
ok(false, "promise should not be fulfilled");
})['catch'](function(err){
Expand All @@ -164,8 +142,7 @@ test('sometimes async gets rejected', function(){
});
```

Helpers
-------
## Test Helpers

### `moduleFor(fullName [, description [, callbacks]])`

Expand All @@ -188,23 +165,41 @@ Helpers
- `name`: (String) - the short name of the model you'd use in `store`
operations ie `user`, `assignmentGroup`, etc.

Contributing
------------
## Contributing

Contributions are welcome. Please follow the instructions below to install and
test this library.

### Installation

```sh
$ npm install -g bower broccoli-cli
$ npm install
$ bower install
$ npm install -g karma-cli broccoli-cli
```

### Testing

In order to test in the browser:

```sh
$ broccoli serve
# new tab
$ karma start
```

Building dist/
--------------
... and then visit [http://localhost:4200/tests](http://localhost:4200/tests).

In order to perform a CI test:

```sh
$ broccoli build dist
# Broccoli will not overwrite dist/, so you
# may need to delete it first
$ rm -rf build && BROCCOLI_ENV=test broccoli build build && testem ci
```

Or simply:

```sh
$ npm test
```

## Copyright and License

Copyright 2014 Ryan Florence and contributors. [MIT License](./LICENSE).
14 changes: 11 additions & 3 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,27 @@
"version": "0.1.8",
"authors": [
"Stefan Penner",
"Ryan Florence"
"Ryan Florence",
"Robert Jackson",
"Dan Gebhardt"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test"
"tests"
],
"dependencies": {
"ember": "^1.3.0"
"ember": "^1.7.0",
"ember-test-helpers": "^0.0.6"
},
"devDependencies": {
"qunit": "^1.15.0",
"loader": "stefanpenner/loader.js#1.0.1",
"ember-cli-shims": "stefanpenner/ember-cli-shims#0.0.3",
"ember-cli-test-loader": "rwjblue/ember-cli-test-loader#0.0.4",
"jquery": "~2.1.1",
"ember-data": "~1.0.0-beta.10"
}
}
23 changes: 0 additions & 23 deletions dist/amd/isolated-container.js

This file was deleted.

33 changes: 0 additions & 33 deletions dist/amd/main.js

This file was deleted.

64 changes: 0 additions & 64 deletions dist/amd/module-for-component.js

This file was deleted.

0 comments on commit 778f806

Please sign in to comment.