This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -1087,6 +1087,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
10871087 * @returns {ng.$compileProvider } Self for chaining.
10881088 */
10891089 this . directive = function registerDirective ( name , directiveFactory ) {
1090+ assertArg ( name , 'name' ) ;
10901091 assertNotHasOwnProperty ( name , 'directive' ) ;
10911092 if ( isString ( name ) ) {
10921093 assertValidDirectiveName ( name ) ;
Original file line number Diff line number Diff line change @@ -214,6 +214,7 @@ describe('$compile', function() {
214214 } ) ;
215215 inject ( function ( $compile ) { } ) ;
216216 } ) ;
217+
217218 it ( 'should throw an exception if a directive name has leading or trailing whitespace' , function ( ) {
218219 module ( function ( ) {
219220 function assertLeadingOrTrailingWhitespaceInDirectiveName ( name ) {
@@ -230,6 +231,24 @@ describe('$compile', function() {
230231 inject ( function ( $compile ) { } ) ;
231232 } ) ;
232233
234+ it ( 'should throw an exception if the directive name is not defined' , function ( ) {
235+ module ( function ( ) {
236+ expect ( function ( ) {
237+ directive ( ) ;
238+ } ) . toThrowMinErr ( 'ng' , 'areq' ) ;
239+ } ) ;
240+ inject ( function ( $compile ) { } ) ;
241+ } ) ;
242+
243+ it ( 'should throw an exception if the directive factory is not defined' , function ( ) {
244+ module ( function ( ) {
245+ expect ( function ( ) {
246+ directive ( 'myDir' ) ;
247+ } ) . toThrowMinErr ( 'ng' , 'areq' ) ;
248+ } ) ;
249+ inject ( function ( $compile ) { } ) ;
250+ } ) ;
251+
233252 it ( 'should preserve context within declaration' , function ( ) {
234253 module ( function ( ) {
235254 directive ( 'ff' , function ( log ) {
You can’t perform that action at this time.
0 commit comments