@@ -2127,11 +2127,9 @@ describe('$compile', function() {
2127
2127
describe ( 'scope' , function ( ) {
2128
2128
var iscope ;
2129
2129
2130
- var fakeScopeMdl = angular . module ( 'fakeScopeMdl' , [ ] ) ;
2131
-
2132
- forEach ( [ '' , 'a' , 'b' ] , function ( name ) {
2133
- fakeScopeMdl
2134
- . directive ( 'scope' + uppercase ( name ) , function ( log ) {
2130
+ beforeEach ( module ( function ( ) {
2131
+ forEach ( [ '' , 'a' , 'b' ] , function ( name ) {
2132
+ directive ( 'scope' + uppercase ( name ) , function ( log ) {
2135
2133
return {
2136
2134
scope : true ,
2137
2135
restrict : 'CA' ,
@@ -2142,8 +2140,8 @@ describe('$compile', function() {
2142
2140
} } ;
2143
2141
}
2144
2142
} ;
2145
- } )
2146
- . directive ( 'iscope' + uppercase ( name ) , function ( log ) {
2143
+ } ) ;
2144
+ directive ( 'iscope' + uppercase ( name ) , function ( log ) {
2147
2145
return {
2148
2146
scope : { } ,
2149
2147
restrict : 'CA' ,
@@ -2155,8 +2153,8 @@ describe('$compile', function() {
2155
2153
} ;
2156
2154
}
2157
2155
} ;
2158
- } )
2159
- . directive ( 'tscope' + uppercase ( name ) , function ( log ) {
2156
+ } ) ;
2157
+ directive ( 'tscope' + uppercase ( name ) , function ( log ) {
2160
2158
return {
2161
2159
scope : true ,
2162
2160
restrict : 'CA' ,
@@ -2168,8 +2166,8 @@ describe('$compile', function() {
2168
2166
} ;
2169
2167
}
2170
2168
} ;
2171
- } )
2172
- . directive ( 'stscope' + uppercase ( name ) , function ( log ) {
2169
+ } ) ;
2170
+ directive ( 'stscope' + uppercase ( name ) , function ( log ) {
2173
2171
return {
2174
2172
scope : true ,
2175
2173
restrict : 'CA' ,
@@ -2181,8 +2179,8 @@ describe('$compile', function() {
2181
2179
} ;
2182
2180
}
2183
2181
} ;
2184
- } )
2185
- . directive ( 'trscope' + uppercase ( name ) , function ( log ) {
2182
+ } ) ;
2183
+ directive ( 'trscope' + uppercase ( name ) , function ( log ) {
2186
2184
return {
2187
2185
scope : true ,
2188
2186
replace : true ,
@@ -2195,8 +2193,8 @@ describe('$compile', function() {
2195
2193
} ;
2196
2194
}
2197
2195
} ;
2198
- } )
2199
- . directive ( 'tiscope' + uppercase ( name ) , function ( log ) {
2196
+ } ) ;
2197
+ directive ( 'tiscope' + uppercase ( name ) , function ( log ) {
2200
2198
return {
2201
2199
scope : { } ,
2202
2200
restrict : 'CA' ,
@@ -2209,8 +2207,8 @@ describe('$compile', function() {
2209
2207
} ;
2210
2208
}
2211
2209
} ;
2212
- } )
2213
- . directive ( 'stiscope' + uppercase ( name ) , function ( log ) {
2210
+ } ) ;
2211
+ directive ( 'stiscope' + uppercase ( name ) , function ( log ) {
2214
2212
return {
2215
2213
scope : { } ,
2216
2214
restrict : 'CA' ,
@@ -2224,19 +2222,17 @@ describe('$compile', function() {
2224
2222
}
2225
2223
} ;
2226
2224
} ) ;
2227
- } ) ;
2228
-
2229
- fakeScopeMdl
2230
- . directive ( 'log' , function ( log ) {
2225
+ } ) ;
2226
+ directive ( 'log' , function ( log ) {
2231
2227
return {
2232
2228
restrict : 'CA' ,
2233
2229
link : { pre : function ( scope ) {
2234
2230
log ( 'log-' + scope . $id + '-' + ( scope . $parent && scope . $parent . $id || 'no-parent' ) ) ;
2235
2231
} }
2236
2232
} ;
2237
2233
} ) ;
2234
+ } ) ) ;
2238
2235
2239
- beforeEach ( module ( 'fakeScopeMdl' ) ) ;
2240
2236
2241
2237
it ( 'should allow creation of new scopes' , inject ( function ( $rootScope , $compile , log ) {
2242
2238
element = $compile ( '<div><span scope><a log></a></span></div>' ) ( $rootScope ) ;
@@ -2339,7 +2335,7 @@ describe('$compile', function() {
2339
2335
function ( $rootScope , $compile ) {
2340
2336
expect ( function ( ) {
2341
2337
$compile ( '<div class="iscope-a; scope-b"></div>' ) ;
2342
- } ) . toThrowMinErr ( '$compile' , 'multidir' , 'Multiple directives [iscopeA (module: fakeScopeMdl) , scopeB (module: fakeScopeMdl) ] asking for new/isolated scope on: ' +
2338
+ } ) . toThrowMinErr ( '$compile' , 'multidir' , 'Multiple directives [iscopeA, scopeB] asking for new/isolated scope on: ' +
2343
2339
'<div class="iscope-a; scope-b">' ) ;
2344
2340
} )
2345
2341
) ;
@@ -2358,7 +2354,7 @@ describe('$compile', function() {
2358
2354
inject ( function ( $compile ) {
2359
2355
expect ( function ( ) {
2360
2356
$compile ( '<div class="iscope-a; high-priority-scope"></div>' ) ;
2361
- } ) . toThrowMinErr ( '$compile' , 'multidir' , 'Multiple directives [highPriorityScope, iscopeA (module: fakeScopeMdl) ] asking for new/isolated scope on: ' +
2357
+ } ) . toThrowMinErr ( '$compile' , 'multidir' , 'Multiple directives [highPriorityScope, iscopeA] asking for new/isolated scope on: ' +
2362
2358
'<div class="iscope-a; high-priority-scope">' ) ;
2363
2359
} ) ;
2364
2360
} ) ;
@@ -2518,6 +2514,70 @@ describe('$compile', function() {
2518
2514
) ;
2519
2515
} ) ;
2520
2516
} ) ;
2517
+
2518
+ describe ( 'multidir isolated scope error messages' , function ( ) {
2519
+ angular . module ( 'fakeIsoledScopeModule' , [ ] )
2520
+ . directive ( 'fakeScope' , function ( log ) {
2521
+ return {
2522
+ scope : true ,
2523
+ restrict : 'CA' ,
2524
+ compile : function ( ) {
2525
+ return { pre : function ( scope , element ) {
2526
+ log ( scope . $id ) ;
2527
+ expect ( element . data ( '$scope' ) ) . toBe ( scope ) ;
2528
+ } } ;
2529
+ }
2530
+ } ;
2531
+ } )
2532
+ . directive ( 'fakeIScope' , function ( log ) {
2533
+ return {
2534
+ scope : { } ,
2535
+ restrict : 'CA' ,
2536
+ compile : function ( ) {
2537
+ return function ( scope , element ) {
2538
+ iscope = scope ;
2539
+ log ( scope . $id ) ;
2540
+ expect ( element . data ( '$isolateScopeNoTemplate' ) ) . toBe ( scope ) ;
2541
+ } ;
2542
+ }
2543
+ } ;
2544
+ } ) ;
2545
+
2546
+ beforeEach ( module ( 'fakeIsoledScopeModule' , function ( ) {
2547
+ directive ( 'anonymModuleScopeDirective' , function ( log ) {
2548
+ return {
2549
+ scope : true ,
2550
+ restrict : 'CA' ,
2551
+ compile : function ( ) {
2552
+ return { pre : function ( scope , element ) {
2553
+ log ( scope . $id ) ;
2554
+ expect ( element . data ( '$scope' ) ) . toBe ( scope ) ;
2555
+ } } ;
2556
+ }
2557
+ } ;
2558
+ } ) ;
2559
+ } ) ) ;
2560
+
2561
+ it ( 'should add module name to multidir isolated scope message if directive defined through module' , inject (
2562
+ function ( $rootScope , $compile ) {
2563
+ expect ( function ( ) {
2564
+ $compile ( '<div class="fake-scope; fake-i-scope"></div>' ) ;
2565
+ } ) . toThrowMinErr ( '$compile' , 'multidir' ,
2566
+ 'Multiple directives [fakeIScope (module: fakeIsoledScopeModule), fakeScope (module: fakeIsoledScopeModule)] ' +
2567
+ 'asking for new/isolated scope on: <div class="fake-scope; fake-i-scope">' ) ;
2568
+ } )
2569
+ ) ;
2570
+
2571
+ it ( 'sholdn\'t add module name to multidir isolated scope message if directive is defined directly with $compileProvider' , inject (
2572
+ function ( $rootScope , $compile ) {
2573
+ expect ( function ( ) {
2574
+ $compile ( '<div class="anonym-module-scope-directive; fake-i-scope"></div>' ) ;
2575
+ } ) . toThrowMinErr ( '$compile' , 'multidir' ,
2576
+ 'Multiple directives [anonymModuleScopeDirective, fakeIScope (module: fakeIsoledScopeModule)] ' +
2577
+ 'asking for new/isolated scope on: <div class="anonym-module-scope-directive; fake-i-scope">' ) ;
2578
+ } )
2579
+ ) ;
2580
+ } ) ;
2521
2581
} ) ;
2522
2582
} ) ;
2523
2583
} ) ;
0 commit comments