1
- fdescribe ( 'md-button' , function ( ) {
1
+ describe ( 'md-button' , function ( ) {
2
2
3
3
beforeEach ( module ( 'material.components.button' ) ) ;
4
4
@@ -9,47 +9,50 @@ fdescribe('md-button', function() {
9
9
expect ( button [ 0 ] ) . toHaveClass ( 'hide-sm' ) ;
10
10
} ) ) ;
11
11
12
- it ( 'should only have one ripple container when a custom ripple color is set' , inject ( function ( $compile , $rootScope , $timeout ) {
13
- var button = $compile ( '<md-button md-ink-ripple="#f00">button</md-button>' ) ( $rootScope ) ;
12
+ describe ( 'with ARIA support' , function ( ) {
14
13
15
- button . triggerHandler ( { type : '$md.pressdown' , pointer : { x : 0 , y : 0 } } ) ;
16
- expect ( button [ 0 ] . getElementsByClassName ( 'md-ripple-container' ) . length ) . toBe ( 0 ) ;
17
- } ) ) ;
14
+ it ( 'should only have one ripple container when a custom ripple color is set' , inject ( function ( $compile , $rootScope ) {
15
+ var button = $compile ( '<md-button md-ink-ripple="#f00">button</md-button>' ) ( $rootScope ) ;
18
16
17
+ button . triggerHandler ( { type : '$md.pressdown' , pointer : { x : 0 , y : 0 } } ) ;
18
+ expect ( button [ 0 ] . getElementsByClassName ( 'md-ripple-container' ) . length ) . toBe ( 0 ) ;
19
+ } ) ) ;
19
20
20
- it ( 'should expect an aria-label if element has no text' , inject ( function ( $compile , $rootScope , $log ) {
21
- spyOn ( $log , 'warn' ) ;
22
- var button = $compile ( '<md-button><md-icon></md-icon></md-button>' ) ( $rootScope ) ;
23
- $rootScope . $apply ( ) ;
24
- expect ( $log . warn ) . toHaveBeenCalled ( ) ;
25
21
26
- $log . warn . calls . reset ( ) ;
27
- button = $compile ( '<md-button aria-label="something"><md-icon></md-icon></md-button>' ) ( $rootScope ) ;
28
- $rootScope . $apply ( ) ;
29
- expect ( $log . warn ) . not . toHaveBeenCalled ( ) ;
30
- } ) ) ;
22
+ it ( 'should expect an aria-label if element has no text' , inject ( function ( $compile , $rootScope , $log ) {
23
+ spyOn ( $log , 'warn' ) ;
24
+ var button = $compile ( '<md-button><md-icon></md-icon></md-button>' ) ( $rootScope ) ;
25
+ $rootScope . $apply ( ) ;
26
+ expect ( $log . warn ) . toHaveBeenCalled ( ) ;
27
+
28
+ $log . warn . calls . reset ( ) ;
29
+ button = $compile ( '<md-button aria-label="something"><md-icon></md-icon></md-button>' ) ( $rootScope ) ;
30
+ $rootScope . $apply ( ) ;
31
+ expect ( $log . warn ) . not . toHaveBeenCalled ( ) ;
32
+ } ) ) ;
31
33
32
- it ( 'should expect an aria-label if element has text content' , inject ( function ( $compile , $rootScope , $log ) {
33
- spyOn ( $log , 'warn' ) ;
34
+ it ( 'should expect an aria-label if element has text content' , inject ( function ( $compile , $rootScope , $log ) {
35
+ spyOn ( $log , 'warn' ) ;
34
36
35
- var button = $compile ( '<md-button>Hello</md-button>' ) ( $rootScope ) ;
36
- expect ( button . attr ( 'aria-label' ) ) . toBe ( "Hello" ) ;
37
- expect ( $log . warn ) . not . toHaveBeenCalled ( ) ;
38
- } ) ) ;
37
+ var button = $compile ( '<md-button>Hello</md-button>' ) ( $rootScope ) ;
38
+ expect ( button . attr ( 'aria-label' ) ) . toBe ( "Hello" ) ;
39
+ expect ( $log . warn ) . not . toHaveBeenCalled ( ) ;
40
+ } ) ) ;
39
41
40
- it ( 'should set an aria-label if the text content using bindings' , inject ( function ( $$rAF , $compile , $rootScope , $log ) {
41
- spyOn ( $log , 'warn' ) ;
42
+ it ( 'should set an aria-label if the text content using bindings' , inject ( function ( $$rAF , $compile , $rootScope , $log , $timeout ) {
43
+ spyOn ( $log , 'warn' ) ;
42
44
43
- var scope = angular . extend ( $rootScope . $new ( ) , { greetings : "Welcome" } ) ;
44
- var button = $compile ( '<md-button>{{greetings}}</md-button>' ) ( scope ) ;
45
+ var scope = angular . extend ( $rootScope . $new ( ) , { greetings : "Welcome" } ) ;
46
+ var button = $compile ( '<md-button>{{greetings}}</md-button>' ) ( scope ) ;
45
47
46
- $rootScope . $apply ( ) ;
47
- $$rAF . flush ( ) ; // needed for $mdAria.expectAsync()
48
+ $rootScope . $apply ( ) ;
49
+ $$rAF . flush ( ) ; // needed for $mdAria.expectAsync()
48
50
49
- expect ( button . attr ( 'aria-label' ) ) . toBe ( "Welcome" ) ;
50
- expect ( $log . warn ) . not . toHaveBeenCalled ( ) ;
51
- } ) ) ;
51
+ expect ( button . attr ( 'aria-label' ) ) . toBe ( "Welcome" ) ;
52
+ expect ( $log . warn ) . not . toHaveBeenCalled ( ) ;
53
+ } ) ) ;
52
54
55
+ } ) ;
53
56
54
57
it ( 'should allow attribute directive syntax' , inject ( function ( $compile , $rootScope ) {
55
58
var button = $compile ( '<a md-button href="https://google.com">google</a>' ) ( $rootScope . $new ( ) ) ;
0 commit comments