-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(generators/demo): replace mocha/chai based testing framework wit…
…h a combo of karma, jasmine, phantomjs and browserify Omitted when `generators/app` was changed on commit 925d1ca.
- Loading branch information
Showing
5 changed files
with
94 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
90 changes: 90 additions & 0 deletions
90
generators/demo/templates/test/unit/spec/models/example.spec.coffee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
'use strict' | ||
|
||
ExampleModel = require( './../../../../src/models/example.coffee' ) | ||
|
||
describe( 'An `ExampleModel` unit test suite', () -> | ||
|
||
## Create an instance without any data to test the defaults. | ||
## | ||
emptyModel = new ExampleModel() | ||
|
||
describe( 'A newly created model instance without an `attributes` argument', () -> | ||
|
||
it( 'should have a default `attributeOne` attribute of type `String`', () -> | ||
expect( emptyModel.get( 'attributeOne' )).toEqual( jasmine.any( String )) | ||
|
||
return | ||
) | ||
|
||
it( 'should have a default `attributeTwo` attribute of type `Boolean`', () -> | ||
expect( emptyModel.get( 'attributeTwo' )).toEqual( jasmine.any( Boolean )) | ||
|
||
return | ||
) | ||
|
||
return | ||
) | ||
|
||
## Test the set function by overwriting one of the defaults. | ||
## | ||
describe( 'A default attribute, when set', () -> | ||
|
||
it( 'should be overridden', () -> | ||
|
||
newString = 'This should be overriden now' | ||
|
||
emptyModel.set( 'attributeOne', newString ) | ||
|
||
expect( emptyModel.get( 'attributeOne' )).toEqual( newString ) | ||
|
||
return | ||
) | ||
|
||
return | ||
) | ||
|
||
## Test model when xxx it data, check if defaults are overriden | ||
## | ||
populatedModel = | ||
new ExampleModel( | ||
|
||
attributeOne: 'This should be overriden now' | ||
attributeTwo: false | ||
) | ||
|
||
describe( 'A newly created model instance with a custom `attributes` argument', () -> | ||
|
||
it( 'Should have been populated with the attributes as they were passed-in on its constructor', () -> | ||
|
||
expect( populatedModel.get( 'attributeOne' )).toEqual( 'This should be overriden now' ) | ||
expect( populatedModel.get( 'attributeTwo' )).toEqual( false ) | ||
|
||
return | ||
) | ||
|
||
return | ||
) | ||
|
||
## Test an async method. | ||
## | ||
describe( 'A custom async method', () -> | ||
|
||
it( 'it should return true', ( done ) -> | ||
|
||
emptyModel.exampleAsyncFunction( ( response ) -> | ||
|
||
expect( response ).toEqual( true ) | ||
|
||
done() | ||
|
||
return | ||
) | ||
|
||
return | ||
) | ||
|
||
return | ||
) | ||
|
||
return | ||
) |