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

Commit

Permalink
fix(templates): new scope for directive spec
Browse files Browse the repository at this point in the history
To mirror the controller spec template, the generated tests for directives now
mock a new scope instead of working directly on the $rootScope.
  • Loading branch information
passy authored and btford committed Jul 29, 2013
1 parent cd46aa8 commit 2753c99
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 12 deletions.
11 changes: 8 additions & 3 deletions templates/coffeescript-min/spec/directive.coffee
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
'use strict'

describe 'Directive: <%= _.camelize(name) %>', () ->

# load the directive's module
beforeEach module '<%= _.camelize(appname) %>App'

element = {}
scope = {}

beforeEach inject ($controller, $rootScope) ->
scope = $rootScope.$new()

it 'should make hidden element visible', inject ($rootScope, $compile) ->
it 'should make hidden element visible', inject ($compile) ->
element = angular.element '<<%= _.dasherize(name) %>></<%= _.dasherize(name) %>>'
element = $compile(element) $rootScope
element = $compile(element) scope
expect(element.text()).toBe 'this is the <%= _.camelize(name) %> directive'
11 changes: 8 additions & 3 deletions templates/coffeescript/spec/directive.coffee
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
'use strict'

describe 'Directive: <%= _.camelize(name) %>', () ->

# load the directive's module
beforeEach module '<%= _.camelize(appname) %>App'

element = {}
scope = {}

beforeEach inject ($controller, $rootScope) ->
scope = $rootScope.$new()

it 'should make hidden element visible', inject ($rootScope, $compile) ->
it 'should make hidden element visible', inject ($compile) ->
element = angular.element '<<%= _.dasherize(name) %>></<%= _.dasherize(name) %>>'
element = $compile(element) $rootScope
element = $compile(element) scope
expect(element.text()).toBe 'this is the <%= _.camelize(name) %> directive'
13 changes: 10 additions & 3 deletions templates/javascript-min/spec/directive.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
'use strict';

describe('Directive: <%= _.camelize(name) %>', function () {

// load the directive's module
beforeEach(module('<%= _.camelize(appname) %>App'));

var element;
var element,
scope;

beforeEach(inject(function ($rootScope) {
scope = $rootScope.$new();
}));

it('should make hidden element visible', inject(function ($rootScope, $compile) {
it('should make hidden element visible', inject(function ($compile) {
element = angular.element('<<%= _.dasherize(name) %>></<%= _.dasherize(name) %>>');
element = $compile(element)($rootScope);
element = $compile(element)(scope);
expect(element.text()).toBe('this is the <%= _.camelize(name) %> directive');
}));
});
13 changes: 10 additions & 3 deletions templates/javascript/spec/directive.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
'use strict';

describe('Directive: <%= _.camelize(name) %>', function () {

// load the directive's module
beforeEach(module('<%= _.camelize(appname) %>App'));

var element;
var element,
scope;

beforeEach(inject(function ($rootScope) {
scope = $rootScope.$new();
}));

it('should make hidden element visible', inject(function ($rootScope, $compile) {
it('should make hidden element visible', inject(function ($compile) {
element = angular.element('<<%= _.dasherize(name) %>></<%= _.dasherize(name) %>>');
element = $compile(element)($rootScope);
element = $compile(element)(scope);
expect(element.text()).toBe('this is the <%= _.camelize(name) %> directive');
}));
});

0 comments on commit 2753c99

Please sign in to comment.