This repository has been archived by the owner on Mar 26, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(templates): new scope for directive spec
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
Showing
4 changed files
with
36 additions
and
12 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
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' |
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 |
---|---|---|
@@ -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' |
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 |
---|---|---|
@@ -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'); | ||
})); | ||
}); |
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 |
---|---|---|
@@ -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'); | ||
})); | ||
}); |