@@ -6,24 +6,22 @@ describe('ui.grid.utilService', function() {
6
6
$q ,
7
7
$interpolateProvider ;
8
8
9
- beforeEach ( function ( ) {
10
- module ( 'ui.grid' , function ( _$interpolateProvider_ ) {
11
- $interpolateProvider = _$interpolateProvider_ ;
12
- } ) ;
13
-
14
- inject ( function ( _$rootScope_ , _$q_ , _gridUtil_ , _$window_ , _Grid_ ) {
15
- gridUtil = _gridUtil_ ;
16
- $window = _$window_ ;
17
- Grid = _Grid_ ;
18
- $rootScope = _$rootScope_ ;
19
- $q = _$q_ ;
20
- } ) ;
21
- } ) ;
9
+ beforeEach ( module ( 'ui.grid' , function ( _$interpolateProvider_ ) {
10
+ $interpolateProvider = _$interpolateProvider_ ;
11
+ } ) ) ;
12
+
13
+ beforeEach ( inject ( function ( _$rootScope_ , _$q_ , _gridUtil_ , _$window_ , _Grid_ ) {
14
+ gridUtil = _gridUtil_ ;
15
+ $window = _$window_ ;
16
+ Grid = _Grid_ ;
17
+ $rootScope = _$rootScope_ ;
18
+ $q = _$q_ ;
19
+ } ) ) ;
22
20
23
21
describe ( 'newId()' , function ( ) {
24
22
it ( 'creates a unique id each time it is called' , function ( ) {
25
- var id1 = gridUtil . newId ( ) ,
26
- id2 = gridUtil . newId ( ) ;
23
+ var id1 = gridUtil . newId ( ) ;
24
+ var id2 = gridUtil . newId ( ) ;
27
25
28
26
expect ( id1 ) . not . toEqual ( id2 ) ;
29
27
} ) ;
@@ -534,14 +532,12 @@ describe('ui.grid.utilService', function() {
534
532
/* Create Button1 */
535
533
button1 = document . createElement ( 'button' ) ;
536
534
aButton1 = angular . element ( button1 ) ;
537
- aButton1 . attr ( 'id' , 'aButton1' ) ;
538
535
aButton1 . attr ( 'type' , 'button' ) ;
539
536
// The class is not set here because it is set inside of tests if needed
540
537
541
538
/* Create Button2 */
542
539
button2 = document . createElement ( 'button' ) ;
543
540
aButton2 = angular . element ( button1 ) ;
544
- aButton2 . attr ( 'id' , 'aButton2' ) ;
545
541
aButton2 . attr ( 'type' , 'button' ) ;
546
542
aButton2 . addClass ( button2class ) ;
547
543
@@ -561,61 +557,14 @@ describe('ui.grid.utilService', function() {
561
557
expect ( element . innerHTML ) . toEqual ( document . activeElement . innerHTML ) ;
562
558
}
563
559
564
- describe ( 'byId' , function ( ) {
565
- describe ( 'when the grid is not defined' , function ( ) {
566
- it ( 'should focus on the element with the id passed' , function ( ) {
567
- gridUtil . focus . byId ( 'aButton2' ) ;
568
- $timeout . flush ( ) ;
569
-
570
- expectFocused ( button2 ) ;
571
- } ) ;
572
- } ) ;
573
- describe ( 'when the grid is defined' , function ( ) {
574
- it ( 'should focus on the element with the grid id and the id passed' , function ( ) {
575
- var gridId = 'gridId' ;
576
-
577
- aButton2 . attr ( 'id' , 'gridId-aButton2' ) ;
578
- gridUtil . focus . byId ( 'aButton2' , { id : gridId } ) ;
579
- $timeout . flush ( ) ;
580
-
581
- expectFocused ( button2 ) ;
582
- } ) ;
583
- } ) ;
584
- describe ( 'when the id passed in is not in the dom' , function ( ) {
585
- it ( 'should keep focus on the body' , function ( ) {
586
- gridUtil . focus . byId ( 'notAnElement' ) ;
587
- $timeout . flush ( ) ;
588
-
589
- expectFocused ( document . body ) ;
590
- } ) ;
591
- } ) ;
592
- } ) ;
593
560
describe ( 'byElement' , function ( ) {
594
- describe ( 'when argument passed is an element' , function ( ) {
595
- it ( 'should focus on the element passed' , function ( ) {
596
- gridUtil . focus . byElement ( button1 ) ;
597
- $timeout . flush ( ) ;
598
- expectFocused ( button1 ) ;
599
- } ) ;
600
- } ) ;
601
- describe ( 'when argument passed is not an element' , function ( ) {
602
- it ( 'should keep focus on the body' , function ( ) {
603
- gridUtil . focus . byElement ( '' ) ;
604
- expectFocused ( document . body ) ;
605
- } ) ;
561
+ it ( 'should focus on the element passed' , function ( ) {
562
+ gridUtil . focus . byElement ( button1 ) ;
563
+ $timeout . flush ( ) ;
564
+ expectFocused ( button1 ) ;
606
565
} ) ;
607
566
} ) ;
608
567
describe ( 'bySelector' , function ( ) {
609
- describe ( 'when argument passed is not an element' , function ( ) {
610
- it ( 'should throw an error' , function ( done ) {
611
- try {
612
- gridUtil . focus . bySelector ( '' ) ;
613
- } catch ( error ) {
614
- expect ( error . message ) . toEqual ( 'The parent element is not an element.' ) ;
615
- done ( ) ;
616
- }
617
- } ) ;
618
- } ) ;
619
568
it ( 'should focus on an elment using a selector' , function ( ) {
620
569
gridUtil . focus . bySelector ( elm , '.' + button2class ) ;
621
570
$timeout . flush ( ) ;
0 commit comments