Permalink
Browse files

feat(templates): add provider test scafolding

WIP
  • Loading branch information...
1 parent 1343363 commit 7ec5f63de7898da01c7720c1bf7c817db2781515 @marcin-wosinek marcin-wosinek committed Feb 25, 2015
Showing with 63 additions and 1 deletion.
  1. +1 −1 provider/index.js
  2. +30 −0 templates/coffeescript/spec/provider.coffee
  3. +32 −0 templates/javascript/spec/provider.js
View
@@ -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
);
@@ -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
@@ -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.