@@ -126,10 +126,10 @@ describe('accordion', function () {
126
126
describe ( 'with static panels' , function ( ) {
127
127
beforeEach ( function ( ) {
128
128
var tpl =
129
- '<accordion>' +
130
- '<accordion-group heading="title 1">Content 1</accordion-group>' +
131
- '<accordion-group heading="title 2">Content 2</accordion-group>' +
132
- '</accordion>' ;
129
+ '<accordion>' +
130
+ '<accordion-group heading="title 1">Content 1</accordion-group>' +
131
+ '<accordion-group heading="title 2">Content 2</accordion-group>' +
132
+ '</accordion>' ;
133
133
element = angular . element ( tpl ) ;
134
134
$compile ( element ) ( scope ) ;
135
135
scope . $digest ( ) ;
@@ -172,9 +172,9 @@ describe('accordion', function () {
172
172
var model ;
173
173
beforeEach ( function ( ) {
174
174
var tpl =
175
- '<accordion>' +
176
- '<accordion-group ng-repeat="group in groups" heading="{{group.name}}">{{group.content}}</accordion-group>' +
177
- '</accordion>' ;
175
+ '<accordion>' +
176
+ '<accordion-group ng-repeat="group in groups" heading="{{group.name}}">{{group.content}}</accordion-group>' +
177
+ '</accordion>' ;
178
178
element = angular . element ( tpl ) ;
179
179
model = [
180
180
{ name : 'title 1' , content : 'Content 1' } ,
@@ -217,10 +217,10 @@ describe('accordion', function () {
217
217
describe ( 'is-open attribute' , function ( ) {
218
218
beforeEach ( function ( ) {
219
219
var tpl =
220
- '<accordion>' +
221
- '<accordion-group heading="title 1" is-open="open.first">Content 1</accordion-group>' +
222
- '<accordion-group heading="title 2" is-open="open.second">Content 2</accordion-group>' +
223
- '</accordion>' ;
220
+ '<accordion>' +
221
+ '<accordion-group heading="title 1" is-open="open.first">Content 1</accordion-group>' +
222
+ '<accordion-group heading="title 2" is-open="open.second">Content 2</accordion-group>' +
223
+ '</accordion>' ;
224
224
element = angular . element ( tpl ) ;
225
225
scope . open = { first : false , second : true } ;
226
226
$compile ( element ) ( scope ) ;
@@ -247,10 +247,10 @@ describe('accordion', function () {
247
247
describe ( 'is-open attribute with dynamic content' , function ( ) {
248
248
beforeEach ( function ( ) {
249
249
var tpl =
250
- '<accordion>' +
251
- '<accordion-group heading="title 1" is-open="open1"><div ng-repeat="item in items">{{item}}</div></accordion-group>' +
252
- '<accordion-group heading="title 2" is-open="open2">Static content</accordion-group>' +
253
- '</accordion>' ;
250
+ '<accordion>' +
251
+ '<accordion-group heading="title 1" is-open="open1"><div ng-repeat="item in items">{{item}}</div></accordion-group>' +
252
+ '<accordion-group heading="title 2" is-open="open2">Static content</accordion-group>' +
253
+ '</accordion>' ;
254
254
element = angular . element ( tpl ) ;
255
255
scope . items = [ 'Item 1' , 'Item 2' , 'Item 3' ] ;
256
256
scope . open1 = true ;
@@ -274,9 +274,9 @@ describe('accordion', function () {
274
274
describe ( 'is-open attribute with dynamic groups' , function ( ) {
275
275
beforeEach ( function ( ) {
276
276
var tpl =
277
- '<accordion>' +
278
- '<accordion-group ng-repeat="group in groups" heading="{{group.name}}" is-open="group.open">{{group.content}}</accordion-group>' +
279
- '</accordion>' ;
277
+ '<accordion>' +
278
+ '<accordion-group ng-repeat="group in groups" heading="{{group.name}}" is-open="group.open">{{group.content}}</accordion-group>' +
279
+ '</accordion>' ;
280
280
element = angular . element ( tpl ) ;
281
281
scope . groups = [
282
282
{ name : 'title 1' , content : 'Content 1' , open : false } ,
@@ -310,9 +310,9 @@ describe('accordion', function () {
310
310
var groupBody ;
311
311
beforeEach ( function ( ) {
312
312
var tpl =
313
- '<accordion>' +
314
- '<accordion-group heading="title 1" is-disabled="disabled">Content 1</accordion-group>' +
315
- '</accordion>' ;
313
+ '<accordion>' +
314
+ '<accordion-group heading="title 1" is-disabled="disabled">Content 1</accordion-group>' +
315
+ '</accordion>' ;
316
316
element = angular . element ( tpl ) ;
317
317
scope . disabled = true ;
318
318
$compile ( element ) ( scope ) ;
@@ -340,17 +340,38 @@ describe('accordion', function () {
340
340
scope . $digest ( ) ;
341
341
expect ( groupBody . scope ( ) . isOpen ) . toBeTruthy ( ) ;
342
342
} ) ;
343
+
344
+ it ( 'should have text-muted styling' , function ( ) {
345
+ expect ( findGroupLink ( 0 ) . find ( 'span:first' ) ) . toHaveClass ( 'text-muted' ) ;
346
+ } ) ;
343
347
} ) ;
344
348
349
+ // This is re-used in both the accordion-heading element and the accordion-heading attribute tests
350
+ function isDisabledStyleCheck ( ) {
351
+ var tpl =
352
+ '<accordion ng-init="a = [1,2,3]">' +
353
+ '<accordion-group heading="I get overridden" is-disabled="true">' +
354
+ '<accordion-heading>Heading Element <span ng-repeat="x in a">{{x}}</span> </accordion-heading>' +
355
+ 'Body' +
356
+ '</accordion-group>' +
357
+ '</accordion>' ;
358
+ scope . disabled = true ;
359
+ element = $compile ( tpl ) ( scope ) ;
360
+ scope . $digest ( ) ;
361
+ groups = element . find ( '.panel' ) ;
362
+
363
+ expect ( findGroupLink ( 0 ) . find ( 'span' ) . hasClass ( 'text-muted' ) ) . toBe ( true ) ;
364
+ }
365
+
345
366
describe ( 'accordion-heading element' , function ( ) {
346
367
beforeEach ( function ( ) {
347
368
var tpl =
348
- '<accordion ng-init="a = [1,2,3]">' +
349
- '<accordion-group heading="I get overridden">' +
369
+ '<accordion ng-init="a = [1,2,3]">' +
370
+ '<accordion-group heading="I get overridden">' +
350
371
'<accordion-heading>Heading Element <span ng-repeat="x in a">{{x}}</span> </accordion-heading>' +
351
372
'Body' +
352
- '</accordion-group>' +
353
- '</accordion>' ;
373
+ '</accordion-group>' +
374
+ '</accordion>' ;
354
375
element = $compile ( tpl ) ( scope ) ;
355
376
scope . $digest ( ) ;
356
377
groups = element . find ( '.panel' ) ;
@@ -359,20 +380,25 @@ describe('accordion', function () {
359
380
expect ( findGroupLink ( 0 ) . text ( ) ) . toBe ( 'Heading Element 123 ' ) ;
360
381
} ) ;
361
382
it ( 'attaches the same scope to the transcluded heading and body' , function ( ) {
362
- expect ( findGroupLink ( 0 ) . find ( 'span' ) . scope ( ) . $id ) . toBe ( findGroupBody ( 0 ) . find ( 'span' ) . scope ( ) . $id ) ;
383
+ expect ( findGroupLink ( 0 ) . find ( 'span.ng-scope ' ) . scope ( ) . $id ) . toBe ( findGroupBody ( 0 ) . find ( 'span' ) . scope ( ) . $id ) ;
363
384
} ) ;
385
+ it ( 'should wrap the transcluded content in a span' , function ( ) {
386
+ expect ( findGroupLink ( 0 ) . find ( 'span:first' ) . length ) . toEqual ( 1 ) ;
387
+ } ) ;
388
+
389
+ it ( 'should have disabled styling when is-disabled is true' , isDisabledStyleCheck ) ;
364
390
365
391
} ) ;
366
392
367
393
describe ( 'accordion-heading attribute' , function ( ) {
368
394
beforeEach ( function ( ) {
369
395
var tpl =
370
- '<accordion ng-init="a = [1,2,3]">' +
371
- '<accordion-group heading="I get overridden">' +
396
+ '<accordion ng-init="a = [1,2,3]">' +
397
+ '<accordion-group heading="I get overridden">' +
372
398
'<div accordion-heading>Heading Element <span ng-repeat="x in a">{{x}}</span> </div>' +
373
399
'Body' +
374
- '</accordion-group>' +
375
- '</accordion>' ;
400
+ '</accordion-group>' +
401
+ '</accordion>' ;
376
402
element = $compile ( tpl ) ( scope ) ;
377
403
scope . $digest ( ) ;
378
404
groups = element . find ( '.panel' ) ;
@@ -381,9 +407,11 @@ describe('accordion', function () {
381
407
expect ( findGroupLink ( 0 ) . text ( ) ) . toBe ( 'Heading Element 123 ' ) ;
382
408
} ) ;
383
409
it ( 'attaches the same scope to the transcluded heading and body' , function ( ) {
384
- expect ( findGroupLink ( 0 ) . find ( 'span' ) . scope ( ) . $id ) . toBe ( findGroupBody ( 0 ) . find ( 'span' ) . scope ( ) . $id ) ;
410
+ expect ( findGroupLink ( 0 ) . find ( 'span.ng-scope ' ) . scope ( ) . $id ) . toBe ( findGroupBody ( 0 ) . find ( 'span' ) . scope ( ) . $id ) ;
385
411
} ) ;
386
412
413
+ it ( 'should have disabled styling when is-disabled is true' , isDisabledStyleCheck ) ;
414
+
387
415
} ) ;
388
416
389
417
describe ( 'accordion-heading, with repeating accordion-groups' , function ( ) {
0 commit comments