1
1
describe ( 'carousel' , function ( ) {
2
- beforeEach ( module ( 'ui.bootstrap.carousel' , function ( $compileProvider , $provide ) {
3
- angular . forEach ( [ 'ngSwipeLeft' , 'ngSwipeRight' ] , makeMock ) ;
4
- function makeMock ( name ) {
5
- $provide . value ( name + 'Directive' , [ ] ) ; //remove existing directive if it exists
6
- $compileProvider . directive ( name , function ( ) {
7
- return function ( scope , element , attr ) {
8
- element . on ( name , function ( ) {
9
- scope . $apply ( attr [ name ] ) ;
10
- } ) ;
11
- } ;
12
- } ) ;
13
- }
14
- } ) ) ;
2
+ beforeEach ( module ( 'ui.bootstrap.carousel' ) ) ;
15
3
beforeEach ( module ( 'ngAnimateMock' ) ) ;
16
4
beforeEach ( module ( 'uib/template/carousel/carousel.html' , 'uib/template/carousel/slide.html' ) ) ;
17
5
@@ -36,11 +24,11 @@ describe('carousel', function() {
36
24
{ content : 'three' , index : 2 }
37
25
] ;
38
26
elm = $compile (
39
- '<uib-carousel active="active" interval="interval" no-transition="true" no-pause="nopause">' +
40
- '<uib-slide ng-repeat="slide in slides track by slide.index" index="slide.index">' +
27
+ '<div uib-carousel active="active" interval="interval" no-transition="true" no-pause="nopause">' +
28
+ '<div uib-slide ng-repeat="slide in slides track by slide.index" index="slide.index">' +
41
29
'{{slide.content}}' +
42
- '</uib-slide >' +
43
- '</uib-carousel >'
30
+ '</div >' +
31
+ '</div >'
44
32
) ( scope ) ;
45
33
scope . interval = 5000 ;
46
34
scope . nopause = undefined ;
@@ -60,19 +48,19 @@ describe('carousel', function() {
60
48
it ( 'should allow overriding of the carousel template' , function ( ) {
61
49
$templateCache . put ( 'foo/bar.html' , '<div>foo</div>' ) ;
62
50
63
- elm = $compile ( '<uib-carousel template-url="foo/bar.html"></uib-carousel >' ) ( scope ) ;
51
+ elm = $compile ( '<div uib-carousel template-url="foo/bar.html"></div >' ) ( scope ) ;
64
52
$rootScope . $digest ( ) ;
65
53
66
- expect ( elm . html ( ) ) . toBe ( 'foo' ) ;
54
+ expect ( elm . html ( ) ) . toBe ( '<div> foo</div> ' ) ;
67
55
} ) ;
68
56
69
57
it ( 'should allow overriding of the slide template' , function ( ) {
70
58
$templateCache . put ( 'foo/bar.html' , '<div class="slide">bar</div>' ) ;
71
59
72
60
elm = $compile (
73
- '<uib-carousel interval="interval" no-transition="true" no-pause="nopause">' +
74
- '<uib-slide template-url="foo/bar.html"></uib-slide >' +
75
- '</uib-carousel >'
61
+ '<div uib-carousel interval="interval" no-transition="true" no-pause="nopause">' +
62
+ '<div uib-slide template-url="foo/bar.html"></div >' +
63
+ '</div >'
76
64
) ( scope ) ;
77
65
$rootScope . $digest ( ) ;
78
66
@@ -101,11 +89,11 @@ describe('carousel', function() {
101
89
102
90
it ( 'should stop cycling slides forward when noWrap is truthy' , function ( ) {
103
91
elm = $compile (
104
- '<uib-carousel active="active" interval="interval" no-wrap="noWrap">' +
105
- '<uib-slide ng-repeat="slide in slides track by slide.index" index="slide.index">' +
92
+ '<div uib-carousel active="active" interval="interval" no-wrap="noWrap">' +
93
+ '<div uib-slide ng-repeat="slide in slides track by slide.index" index="slide.index">' +
106
94
'{{slide.content}}' +
107
- '</uib-slide >' +
108
- '</uib-carousel >'
95
+ '</div >' +
96
+ '</div >'
109
97
) ( scope ) ;
110
98
111
99
scope . noWrap = true ;
@@ -124,11 +112,11 @@ describe('carousel', function() {
124
112
125
113
it ( 'should stop cycling slides backward when noWrap is truthy' , function ( ) {
126
114
elm = $compile (
127
- '<uib-carousel active="active" interval="interval" no-wrap="noWrap">' +
128
- '<uib-slide ng-repeat="slide in slides track by slide.index" index="slide.index">' +
115
+ '<div uib-carousel active="active" interval="interval" no-wrap="noWrap">' +
116
+ '<div uib-slide ng-repeat="slide in slides track by slide.index" index="slide.index">' +
129
117
'{{slide.content}}' +
130
- '</uib-slide >' +
131
- '</uib-carousel >'
118
+ '</div >' +
119
+ '</div >'
132
120
) ( scope ) ;
133
121
134
122
scope . noWrap = true ;
@@ -147,11 +135,11 @@ describe('carousel', function() {
147
135
scope . slides = [ { active :false , content :'one' } ] ;
148
136
scope . $apply ( ) ;
149
137
elm = $compile (
150
- '<uib-carousel active="active" interval="interval" no-transition="true">' +
151
- '<uib-slide ng-repeat="slide in slides" index="$index">' +
138
+ '<div uib-carousel active="active" interval="interval" no-transition="true">' +
139
+ '<div uib-slide ng-repeat="slide in slides" index="$index">' +
152
140
'{{slide.content}}' +
153
- '</uib-slide >' +
154
- '</uib-carousel >'
141
+ '</div >' +
142
+ '</div >'
155
143
) ( scope ) ;
156
144
var indicators = elm . find ( 'ol.carousel-indicators > li' ) ;
157
145
expect ( indicators . length ) . toBe ( 0 ) ;
@@ -228,20 +216,6 @@ describe('carousel', function() {
228
216
testSlideActive ( 0 ) ;
229
217
} ) ;
230
218
231
- describe ( 'swiping' , function ( ) {
232
- it ( 'should go next on swipeLeft' , function ( ) {
233
- testSlideActive ( 0 ) ;
234
- elm . triggerHandler ( 'ngSwipeLeft' ) ;
235
- testSlideActive ( 1 ) ;
236
- } ) ;
237
-
238
- it ( 'should go prev on swipeRight' , function ( ) {
239
- testSlideActive ( 0 ) ;
240
- elm . triggerHandler ( 'ngSwipeRight' ) ;
241
- testSlideActive ( 2 ) ;
242
- } ) ;
243
- } ) ;
244
-
245
219
it ( 'should select a slide when clicking on slide indicators' , function ( ) {
246
220
var indicators = elm . find ( 'ol.carousel-indicators > li' ) ;
247
221
indicators . eq ( 1 ) . click ( ) ;
@@ -269,7 +243,7 @@ describe('carousel', function() {
269
243
} ) ;
270
244
271
245
it ( 'should bind the content to slides' , function ( ) {
272
- var contents = elm . find ( 'div.item' ) ;
246
+ var contents = elm . find ( 'div.item [ng-transclude] ' ) ;
273
247
274
248
expect ( contents . length ) . toBe ( 3 ) ;
275
249
expect ( contents . eq ( 0 ) . text ( ) ) . toBe ( 'one' ) ;
@@ -343,7 +317,7 @@ describe('carousel', function() {
343
317
{ content :'new3' , index : 6 }
344
318
] ;
345
319
scope . $apply ( ) ;
346
- var contents = elm . find ( 'div.item' ) ;
320
+ var contents = elm . find ( 'div.item [ng-transclude] ' ) ;
347
321
expect ( contents . length ) . toBe ( 3 ) ;
348
322
expect ( contents . eq ( 0 ) . text ( ) ) . toBe ( 'new1' ) ;
349
323
expect ( contents . eq ( 1 ) . text ( ) ) . toBe ( 'new2' ) ;
@@ -441,11 +415,11 @@ describe('carousel', function() {
441
415
{ content : 'three' , id : 2 }
442
416
] ;
443
417
elm = $compile (
444
- '<uib-carousel active="active" interval="interval" no-transition="true" no-pause="nopause">' +
445
- '<uib-slide ng-repeat="slide in slides | orderBy: \'id\' track by slide.id" index="slide.id">' +
418
+ '<div uib-carousel active="active" interval="interval" no-transition="true" no-pause="nopause">' +
419
+ '<div uib-slide ng-repeat="slide in slides | orderBy: \'id\' track by slide.id" index="slide.id">' +
446
420
'{{slide.content}}' +
447
- '</uib-slide >' +
448
- '</uib-carousel >'
421
+ '</div >' +
422
+ '</div >'
449
423
) ( scope ) ;
450
424
scope . $apply ( ) ;
451
425
} ) ;
@@ -465,7 +439,7 @@ describe('carousel', function() {
465
439
scope . slides [ 1 ] . id = 2 ;
466
440
scope . slides [ 2 ] . id = 1 ;
467
441
scope . $apply ( ) ;
468
- var contents = elm . find ( 'div.item' ) ;
442
+ var contents = elm . find ( 'div.item [ng-transclude] ' ) ;
469
443
expect ( contents . length ) . toBe ( 3 ) ;
470
444
expect ( contents . eq ( 0 ) . text ( ) ) . toBe ( 'three' ) ;
471
445
expect ( contents . eq ( 1 ) . text ( ) ) . toBe ( 'two' ) ;
@@ -491,7 +465,7 @@ describe('carousel', function() {
491
465
scope . slides [ 2 ] . id = 4 ;
492
466
scope . slides . push ( { content :'four' , id : 5 } ) ;
493
467
scope . $apply ( ) ;
494
- var contents = elm . find ( 'div.item' ) ;
468
+ var contents = elm . find ( 'div.item [ng-transclude] ' ) ;
495
469
expect ( contents . length ) . toBe ( 4 ) ;
496
470
expect ( contents . eq ( 0 ) . text ( ) ) . toBe ( 'two' ) ;
497
471
expect ( contents . eq ( 1 ) . text ( ) ) . toBe ( 'one' ) ;
@@ -503,7 +477,7 @@ describe('carousel', function() {
503
477
testSlideActive ( 1 ) ;
504
478
scope . slides . splice ( 1 , 1 ) ;
505
479
scope . $apply ( ) ;
506
- var contents = elm . find ( 'div.item' ) ;
480
+ var contents = elm . find ( 'div.item [ng-transclude] ' ) ;
507
481
expect ( contents . length ) . toBe ( 2 ) ;
508
482
expect ( contents . eq ( 0 ) . text ( ) ) . toBe ( 'three' ) ;
509
483
expect ( contents . eq ( 1 ) . text ( ) ) . toBe ( 'one' ) ;
@@ -583,7 +557,7 @@ describe('carousel', function() {
583
557
$templateCache . put ( 'uib/template/carousel/carousel.html' , '<div>{{carousel.text}}</div>' ) ;
584
558
585
559
var scope = $rootScope . $new ( ) ;
586
- var elm = $compile ( '<uib-carousel interval="bar" no-transition="false" no-pause="true"></uib-carousel >' ) ( scope ) ;
560
+ var elm = $compile ( '<div uib-carousel interval="bar" no-transition="false" no-pause="true"></div >' ) ( scope ) ;
587
561
$rootScope . $digest ( ) ;
588
562
589
563
var ctrl = elm . controller ( 'uibCarousel' ) ;
@@ -593,7 +567,7 @@ describe('carousel', function() {
593
567
ctrl . text = 'foo' ;
594
568
$rootScope . $digest ( ) ;
595
569
596
- expect ( elm . html ( ) ) . toBe ( 'foo' ) ;
570
+ expect ( elm . html ( ) ) . toBe ( '<div class="ng-binding"> foo</div> ' ) ;
597
571
} ) ) ;
598
572
} ) ;
599
573
@@ -605,11 +579,11 @@ describe('carousel', function() {
605
579
{ active :false , content :'three' }
606
580
] ;
607
581
var elm = $compile (
608
- '<uib-carousel active="active" interval="interval" no-transition="true" no-pause="nopause">' +
609
- '<uib-slide ng-repeat="slide in slides" index="$index" actual="slide">' +
582
+ '<div uib-carousel active="active" interval="interval" no-transition="true" no-pause="nopause">' +
583
+ '<div uib-slide ng-repeat="slide in slides" index="$index" actual="slide">' +
610
584
'{{slide.content}}' +
611
- '</uib-slide >' +
612
- '</uib-carousel >'
585
+ '</div >' +
586
+ '</div >'
613
587
) ( scope ) ;
614
588
$rootScope . $digest ( ) ;
615
589
0 commit comments