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) {
1087
1087
* @returns {ng.$compileProvider } Self for chaining.
1088
1088
*/
1089
1089
this . directive = function registerDirective ( name , directiveFactory ) {
1090
+ assertArg ( name , 'name' ) ;
1090
1091
assertNotHasOwnProperty ( name , 'directive' ) ;
1091
1092
if ( isString ( name ) ) {
1092
1093
assertValidDirectiveName ( name ) ;
Original file line number Diff line number Diff line change @@ -214,6 +214,7 @@ describe('$compile', function() {
214
214
} ) ;
215
215
inject ( function ( $compile ) { } ) ;
216
216
} ) ;
217
+
217
218
it ( 'should throw an exception if a directive name has leading or trailing whitespace' , function ( ) {
218
219
module ( function ( ) {
219
220
function assertLeadingOrTrailingWhitespaceInDirectiveName ( name ) {
@@ -230,6 +231,24 @@ describe('$compile', function() {
230
231
inject ( function ( $compile ) { } ) ;
231
232
} ) ;
232
233
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
+
233
252
it ( 'should preserve context within declaration' , function ( ) {
234
253
module ( function ( ) {
235
254
directive ( 'ff' , function ( log ) {
You can’t perform that action at this time.
0 commit comments