@@ -722,17 +722,39 @@ describe("UiView", function() {
722722 beforeEach ( module ( function ( $stateProvider ) {
723723 $stateProvider
724724 . state ( 'main' , { abstract : true , views : { main : { } } } )
725- . state ( 'main.home' , { views : { content : { template : 'home.html' } } } ) ;
725+ . state ( 'main.home' , { views : { content : { template : 'HOME' } } } )
726+ . state ( 'test' , { views : { 'nest' : { template : 'TEST' } } } ) ;
726727 } ) ) ;
727728
728- it ( "shouldn't puke on weird view setups" , inject ( function ( $compile , $rootScope , $q , $state ) {
729+ it ( "shouldn't puke on weird nested view setups" , inject ( function ( $compile , $rootScope , $q , $state ) {
729730 $compile ( '<div ui-view="main"><div ui-view="content"></div></div>' ) ( $rootScope ) ;
730731
731732 $state . go ( 'main.home' ) ;
732733 $q . flush ( ) ;
733734
734735 expect ( $state . current . name ) . toBe ( 'main.home' ) ;
735736 } ) ) ;
737+
738+ // Test for https://github.com/angular-ui/ui-router/issues/3355
739+ it ( "should target weird nested view setups using the view's simple name" , inject ( function ( $compile , $rootScope , $q , $state ) {
740+ let tpl = `
741+ <div>
742+ <div ui-view="main">
743+ MAIN-DEFAULT-
744+ <div ui-view="content">
745+ <div ui-view="nest"></div>
746+ </div>
747+ </div>
748+ </div>
749+ ` ;
750+ let el = $compile ( tpl ) ( $rootScope ) ;
751+
752+ $state . go ( 'test' ) ;
753+ $q . flush ( ) ;
754+
755+ expect ( $state . current . name ) . toBe ( 'test' ) ;
756+ expect ( el . text ( ) . replace ( / \s * / g, "" ) ) . toBe ( 'MAIN-DEFAULT-TEST' ) ;
757+ } ) ) ;
736758} ) ;
737759
738760describe ( 'uiView transclusion' , function ( ) {
0 commit comments