Skip to content
This repository has been archived by the owner on Mar 26, 2018. It is now read-only.

Commit

Permalink
feat(templates): add provider test scafolding
Browse files Browse the repository at this point in the history
WIP
  • Loading branch information
marcin-wosinek committed Feb 26, 2015
1 parent 1343363 commit 7ec5f63
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 1 deletion.
2 changes: 1 addition & 1 deletion provider/index.js
Expand Up @@ -12,7 +12,7 @@ util.inherits(Generator, ScriptBase);
Generator.prototype.createServiceFiles = function createServiceFiles() {
this.generateSourceAndTest(
'service/provider',
'spec/service',
'spec/provider',
'services',
this.options['skip-add'] || false
);
Expand Down
30 changes: 30 additions & 0 deletions templates/coffeescript/spec/provider.coffee
@@ -0,0 +1,30 @@
'use strict'

describe 'Service: <%= cameledName %>', ->

# instantiate service
<%= cameledName %> = {}
init = ->
inject (_<%= cameledName %>_) ->
<%= cameledName %> = _<%= cameledName %>_
return
return

# load the service's module
beforeEach module '<%= scriptAppName %>'

it 'should do something', ->
init()
expect(!!<%= cameledName %>).toBe true
return

it 'should be configurable', ->
module (<%= cameledName %>Provider) ->
<%= cameledName %>Provider.setSalutation 'Lorem ipsum'
return

init()

expect(<%= cameledName %>.greet()).toEqual 'Lorem ipsum'
return
return
32 changes: 32 additions & 0 deletions templates/javascript/spec/provider.js
@@ -0,0 +1,32 @@
'use strict';

describe('Service: <%= cameledName %>', function () {

// instantiate service
var <%= cameledName %>,
init = function () {
inject(function (_<%= cameledName %>_) {
<%= cameledName %> = _<%= cameledName %>_;
});
};

// load the service's module
beforeEach(module('<%= scriptAppName %>'));

it('should do something', function () {
init();

expect(!!<%= cameledName %>).toBe(true);
});

it('should be configurable', function () {
module(function (<%= cameledName %>Provider) {
<%= cameledName %>Provider.setSalutation('Lorem ipsum');
});

init();

expect(<%= cameledName %>.greet()).toEqual('Lorem ipsum');
});

});

0 comments on commit 7ec5f63

Please sign in to comment.