Skip to content

Commit

Permalink
Added example unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Raymond de Wit committed Dec 14, 2014
1 parent 03f29fb commit d71960f
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,25 @@ yo bat:collection
```

## Grunt watch tasks
For watching your files for changes and compile:
For watching your files for changes during development:

```shell
grunt dev
```

## Running unit tests
The template comes with support for unit testing with Mocha and Chai. There is an example included in the demo application
that can be generated by the generator. You can run your tests by using:

```shell
grunt test
```

You might want to consider adding it to your dev task, depending on your workflow.


## Changelog
- 14-12-2014 - Added example unit test and updated readme to include test task
- 13-12-2014 - Moved config.rb from src to root
- 13-12-2014 - Updated dependencies, now running on latests versions of browserify, grunt-browserify etc.
- 11-12-2014 - Added support for generating a model when generating a collection, fixed bug on watch task for index.html
Expand Down
5 changes: 5 additions & 0 deletions generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,11 @@ module.exports = yeoman.generators.Base.extend(
// Copy the bootstrap file
//
this.template( "demo/bootstrap.coffee", "src/bootstrap.coffee" );

// Copy the test example files
//
this.copy( "demo/models/example.coffee", "src/models/example.coffee" );
this.copy( "demo/test/example.coffee", "test/example.coffee" );
}
else {

Expand Down
37 changes: 37 additions & 0 deletions generators/app/templates/demo/models/example.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
( ( factory ) ->
if typeof exports is "object"
module.exports = factory(
require "q"
require "backbone"
)
else if typeof define is "function" and define.amd
define( [
"q"
"backbone"
], factory )

)( ( Q, Backbone ) ->

###*
# Example of a model
#
# @author Raymond de Wit
# @class ExampleModel
# @static
# @extends Backbone.Model
# @moduletype model
# @version 0.1
###
class ExampleModel extends Backbone.Model

defaults:
propertyOne: "this should be a string"
propertyTwo: true


exampleAsyncFunction: ( callback ) ->

setTimeout( () ->
callback( true )
, 1000 )
)

0 comments on commit d71960f

Please sign in to comment.