1+ describe ( 'prefixer' , function ( ) {
2+
3+ beforeEach ( module ( 'material.core' ) ) ;
4+
5+ beforeEach ( inject ( function ( $injector ) {
6+ $mdUtil = $injector . get ( '$mdUtil' ) ;
7+ } ) ) ;
8+
9+ describe ( 'when using an initial parameter' , function ( ) {
10+
11+ it ( 'should correctly prefix a single attribute' , function ( ) {
12+ expect ( $mdUtil . prefixer ( 'ng-click' ) ) . toEqual ( [ 'ng-click' , 'data-ng-click' , 'x-ng-click' ] ) ;
13+ } ) ;
14+
15+ it ( 'should correctly prefix multiple attributes' , function ( ) {
16+ expect ( $mdUtil . prefixer ( [ 'ng-click' , 'ng-href' ] ) )
17+ . toEqual ( [ 'ng-click' , 'ng-href' , 'data-ng-click' , 'x-ng-click' , 'data-ng-href' , 'x-ng-href' ] ) ;
18+ } ) ;
19+
20+ it ( 'should correctly build a selector for a single attribute' , function ( ) {
21+ expect ( $mdUtil . prefixer ( 'ng-click' , true ) ) . toBe ( '[ng-click],[data-ng-click],[x-ng-click]' ) ;
22+ } ) ;
23+
24+ it ( 'should correctly build a selector for multiple attributes' , function ( ) {
25+ expect ( $mdUtil . prefixer ( [ 'ng-click' , 'ng-href' ] , true ) )
26+ . toBe ( '[ng-click],[ng-href],[data-ng-click],[x-ng-click],[data-ng-href],[x-ng-href]' ) ;
27+ } ) ;
28+
29+ } ) ;
30+
31+ describe ( 'when using the returned object' , function ( ) {
32+ var prefixer ;
33+
34+ beforeEach ( function ( ) {
35+ prefixer = $mdUtil . prefixer ( ) ;
36+ } ) ;
37+
38+ describe ( 'and building a list' , function ( ) {
39+
40+ it ( 'should correctly prefix a single attribute' , function ( ) {
41+ expect ( prefixer . buildList ( 'ng-click' ) ) . toEqual ( [ 'ng-click' , 'data-ng-click' , 'x-ng-click' ] ) ;
42+ } ) ;
43+
44+ it ( 'should correctly prefix multiple attributes' , function ( ) {
45+ expect ( prefixer . buildList ( [ 'ng-click' , 'ng-href' ] ) )
46+ . toEqual ( [ 'ng-click' , 'ng-href' , 'data-ng-click' , 'x-ng-click' , 'data-ng-href' , 'x-ng-href' ] ) ;
47+ } ) ;
48+
49+ } ) ;
50+
51+ describe ( 'and building a selector' , function ( ) {
52+
53+ it ( 'should correctly build for a single attribute' , function ( ) {
54+ expect ( prefixer . buildSelector ( 'ng-click' ) ) . toBe ( '[ng-click],[data-ng-click],[x-ng-click]' ) ;
55+ } ) ;
56+
57+ it ( 'should correctly build for multiple attributes' , function ( ) {
58+ expect ( prefixer . buildSelector ( [ 'ng-click' , 'ng-href' ] ) )
59+ . toBe ( '[ng-click],[ng-href],[data-ng-click],[x-ng-click],[data-ng-href],[x-ng-href]' ) ;
60+ } ) ;
61+ } ) ;
62+
63+ describe ( 'and checking for an attribute' , function ( ) {
64+
65+ it ( 'should correctly detect a prefixed attribute' , function ( ) {
66+ var element = angular . element ( '<div data-ng-click="null">' ) ;
67+
68+ expect ( prefixer . hasAttribute ( element , 'ng-click' ) ) . toBe ( true ) ;
69+ } ) ;
70+
71+ it ( 'should correctly detect an un-prefixed attribute' , function ( ) {
72+ var element = angular . element ( '<div ng-click="null">' ) ;
73+
74+ expect ( prefixer . hasAttribute ( element , 'ng-click' ) ) . toBe ( true ) ;
75+ } ) ;
76+
77+ } ) ;
78+
79+ } ) ;
80+
81+ } ) ;
0 commit comments