1
1
import * as angular from "angular" ;
2
+ import { UIRouter } from '@uirouter/core' ;
2
3
3
4
declare let inject ;
4
5
@@ -83,4 +84,46 @@ describe('templateFactory', function () {
83
84
$httpBackend . flush ( ) ;
84
85
} ) ) ;
85
86
} ) ;
87
+
88
+ if ( angular . version . minor >= 5 ) {
89
+ describe ( 'component template builder' , ( ) => {
90
+ let router : UIRouter , el , rootScope ;
91
+ let cmp = { template : 'hi' } ;
92
+
93
+ beforeEach ( ( ) => {
94
+ let mod = angular . module ( 'foo' , [ ] ) ;
95
+ mod . component ( 'myComponent' , cmp ) ;
96
+ mod . component ( 'dataComponent' , cmp ) ;
97
+ mod . component ( 'xComponent' , cmp ) ;
98
+ } ) ;
99
+ beforeEach ( module ( 'foo' ) ) ;
100
+
101
+ beforeEach ( inject ( ( $uiRouter , $compile , $rootScope ) => {
102
+ router = $uiRouter ;
103
+ rootScope = $rootScope ;
104
+ el = $compile ( angular . element ( '<div><ui-view></ui-view></div>' ) ) ( $rootScope . $new ( ) ) ;
105
+ } ) ) ;
106
+
107
+ it ( 'should not prefix the components dom element with anything' , ( ) => {
108
+ router . stateRegistry . register ( { name : 'cmp' , component : 'myComponent' } ) ;
109
+ router . stateService . go ( 'cmp' ) ;
110
+ rootScope . $digest ( ) ;
111
+ expect ( el . html ( ) ) . toMatch ( / \< m y - c o m p o n e n t / ) ;
112
+ } ) ;
113
+
114
+ it ( 'should prefix the components dom element with x- for components named dataFoo' , ( ) => {
115
+ router . stateRegistry . register ( { name : 'cmp' , component : 'dataComponent' } ) ;
116
+ router . stateService . go ( 'cmp' ) ;
117
+ rootScope . $digest ( ) ;
118
+ expect ( el . html ( ) ) . toMatch ( / \< x - d a t a - c o m p o n e n t / ) ;
119
+ } ) ;
120
+
121
+ it ( 'should prefix the components dom element with x- for components named xFoo' , ( ) => {
122
+ router . stateRegistry . register ( { name : 'cmp' , component : 'xComponent' } ) ;
123
+ router . stateService . go ( 'cmp' ) ;
124
+ rootScope . $digest ( ) ;
125
+ expect ( el . html ( ) ) . toMatch ( / \< x - x - c o m p o n e n t / ) ;
126
+ } )
127
+ } ) ;
128
+ }
86
129
} ) ;
0 commit comments