@@ -5,7 +5,6 @@ describe('element-fullscreen template', function() {
5
5
var scope ,
6
6
template ,
7
7
html ,
8
- templateText ,
9
8
content ,
10
9
Styleguide ;
11
10
@@ -35,89 +34,87 @@ describe('element-fullscreen template', function() {
35
34
inject ( function ( $compile ) {
36
35
html = $compile ( template ) ( scope ) ;
37
36
scope . $digest ( ) ;
38
- templateText = html . prop ( 'outerHTML' ) ;
39
- content = angular . element ( html . html ( ) ) . html ( ) ;
37
+ var shadowDom = angular . element ( html [ 2 ] ) ;
38
+ content = angular . element ( shadowDom [ 0 ] ) . find ( 'div' ) . html ( ) ;
40
39
} ) ;
41
40
}
42
41
43
- function expectDirectiveWithoutValue ( directive ) {
44
- var regex = new RegExp ( '\\s+' + directive + '(\\s+|\\>)[^=]' , 'g' ) ;
45
- expect ( template ) . to . match ( regex ) ;
46
- }
42
+ describe ( 'component markup' , function ( ) {
47
43
48
- it ( 'should be wrapped in shadow-dom element' , function ( ) {
49
- expect ( templateText ) . to . match ( / ^ < s h a d o w - d o m / ) ;
50
- expect ( templateText ) . to . match ( / < \/ s h a d o w - d o m > $ / ) ;
51
- } ) ;
44
+ it ( 'should be wrapped in shadow-dom element' , function ( ) {
45
+ expect ( template ) . to . match ( / < s h a d o w - d o m > [ \s \S ] * < \/ s h a d o w - d o m > / ) ;
46
+ } ) ;
52
47
53
- describe ( 'should have directive' , function ( ) {
48
+ describe ( 'should have directive' , function ( ) {
54
49
55
- it ( 'dynamic-compile without value' , function ( ) {
56
- expectDirectiveWithoutValue ( ' dynamic-compile' ) ;
57
- } ) ;
50
+ it ( 'dynamic-compile without value' , function ( ) {
51
+ expect ( template ) . to . match ( / < d i v [ \s \S ] + d y n a m i c - c o m p i l e \S / ) ;
52
+ } ) ;
58
53
59
- it ( 'ng-bind-html' , function ( ) {
60
- expect ( template ) . to . match ( / \s + n g - b i n d - h t m l = " / ) ;
61
- } ) ;
54
+ it ( 'ng-bind-html' , function ( ) {
55
+ expect ( template ) . to . match ( / < d i v [ \s \S ] + n g - b i n d - h t m l = " / ) ;
56
+ } ) ;
62
57
63
- } ) ;
58
+ } ) ;
64
59
65
- describe ( 'directive ng-bind-html' , function ( ) {
60
+ describe ( 'directive ng-bind-html' , function ( ) {
66
61
67
- it ( 'should filter scope.markup through addWrapper and unsafe' , function ( ) {
68
- var dir = 'ng-bind-html="' ,
62
+ it ( 'should filter scope.markup through addWrapper and unsafe' , function ( ) {
63
+ var dir = 'ng-bind-html="' ,
69
64
start = template . indexOf ( dir ) + dir . length ,
70
65
value = template . substring ( start , template . indexOf ( '"' , start ) ) ;
71
- expect ( value ) . to . match ( / m a r k u p \s * \| \s * a d d W r a p p e r \s * \| \s * u n s a f e \s * / ) ;
66
+ expect ( value ) . to . match ( / m a r k u p \s * \| \s * a d d W r a p p e r \s * \| \s * u n s a f e \s * / ) ;
67
+ } ) ;
68
+
72
69
} ) ;
73
70
74
- } ) ;
71
+ describe ( 'when commonClass is not defined' , function ( ) {
75
72
76
- describe ( 'when commonClass is not defined ' , function ( ) {
73
+ describe ( 'template contents should be ' , function ( ) {
77
74
78
- describe ( 'template contents should be' , function ( ) {
75
+ it ( 'an empty string if scope.markup is not set' , function ( ) {
76
+ expect ( content ) . to . eql ( '' ) ;
77
+ } ) ;
79
78
80
- it ( 'an empty string if scope.markup is not set' , function ( ) {
81
- expect ( content ) . to . eql ( '' ) ;
82
- } ) ;
79
+ it ( 'text from scope.markup' , function ( ) {
80
+ scope . markup = 'hello' ;
81
+ compileTemplate ( ) ;
82
+ expect ( content ) . to . eql ( 'hello' ) ;
83
+ } ) ;
83
84
84
- it ( 'text from scope.markup' , function ( ) {
85
- scope . markup = 'hello' ;
86
- compileTemplate ( ) ;
87
- expect ( content ) . to . eql ( 'hello' ) ;
88
- } ) ;
85
+ it ( 'html from scope.markup' , function ( ) {
86
+ var expected = '<p>hello!</p>' ;
87
+ scope . markup = expected ;
88
+ compileTemplate ( ) ;
89
+ expect ( content ) . to . eql ( expected ) ;
90
+ } ) ;
89
91
90
- it ( 'html from scope.markup' , function ( ) {
91
- var expected = '<p>hello!</p>' ;
92
- scope . markup = expected ;
93
- compileTemplate ( ) ;
94
- expect ( content ) . to . eql ( expected ) ;
95
92
} ) ;
96
93
97
94
} ) ;
98
95
99
- } ) ;
96
+ describe ( 'when commonClass is defined' , function ( ) {
100
97
101
- describe ( 'when commonClass is defined' , function ( ) {
98
+ beforeEach ( function ( ) {
99
+ Styleguide . config = {
100
+ data : {
101
+ commonClass : 'foobar'
102
+ }
103
+ } ;
104
+ } ) ;
102
105
103
- beforeEach ( function ( ) {
104
- Styleguide . config = {
105
- data : {
106
- commonClass : 'foobar'
107
- }
108
- } ;
109
- } ) ;
106
+ it ( 'should wrap scope.markup html in <sg-common-class-wrapper> element' , function ( ) {
107
+ scope . markup = '<p>hello!</p>' ;
108
+ compileTemplate ( ) ;
109
+ expect ( content ) . to . contain ( '<p>hello!</p></sg-common-class-wrapper>' ) ;
110
+ } ) ;
110
111
111
- it ( 'should wrap scope.markup html in <sg-common-class-wrapper> element ' , function ( ) {
112
- scope . markup = '<p>hello!</p>' ;
113
- compileTemplate ( ) ;
114
- expect ( content ) . to . contain ( '<p>hello!</p></ sg-common-class-wrapper>' ) ;
115
- } ) ;
112
+ it ( 'wrapper element should have class defined in commonClass ' , function ( ) {
113
+ scope . markup = '<p>hello!</p>' ;
114
+ compileTemplate ( ) ;
115
+ expect ( content ) . to . contain ( '<sg-common-class-wrapper class="foobar"><p>hello!</p >' ) ;
116
+ } ) ;
116
117
117
- it ( 'wrapper element should have class defined in commonClass' , function ( ) {
118
- scope . markup = '<p>hello!</p>' ;
119
- compileTemplate ( ) ;
120
- expect ( content ) . to . contain ( '<sg-common-class-wrapper class="foobar"><p>hello!</p>' ) ;
121
118
} ) ;
122
119
123
120
} ) ;
0 commit comments