@@ -6,24 +6,22 @@ describe('ui.grid.utilService', function() {
66 $q ,
77 $interpolateProvider ;
88
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+ } ) ) ;
2220
2321 describe ( 'newId()' , function ( ) {
2422 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 ( ) ;
2725
2826 expect ( id1 ) . not . toEqual ( id2 ) ;
2927 } ) ;
@@ -534,14 +532,12 @@ describe('ui.grid.utilService', function() {
534532 /* Create Button1 */
535533 button1 = document . createElement ( 'button' ) ;
536534 aButton1 = angular . element ( button1 ) ;
537- aButton1 . attr ( 'id' , 'aButton1' ) ;
538535 aButton1 . attr ( 'type' , 'button' ) ;
539536 // The class is not set here because it is set inside of tests if needed
540537
541538 /* Create Button2 */
542539 button2 = document . createElement ( 'button' ) ;
543540 aButton2 = angular . element ( button1 ) ;
544- aButton2 . attr ( 'id' , 'aButton2' ) ;
545541 aButton2 . attr ( 'type' , 'button' ) ;
546542 aButton2 . addClass ( button2class ) ;
547543
@@ -561,61 +557,14 @@ describe('ui.grid.utilService', function() {
561557 expect ( element . innerHTML ) . toEqual ( document . activeElement . innerHTML ) ;
562558 }
563559
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- } ) ;
593560 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 ) ;
606565 } ) ;
607566 } ) ;
608567 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- } ) ;
619568 it ( 'should focus on an elment using a selector' , function ( ) {
620569 gridUtil . focus . bySelector ( elm , '.' + button2class ) ;
621570 $timeout . flush ( ) ;
0 commit comments