@@ -9,9 +9,8 @@ describe('uiTemplates', function() {
9
9
// override uiConfig for testing purposes, this definition will clobber anything already predefined ... so be careful
10
10
angular . module ( 'ui.config' , [ ] )
11
11
. value ( 'ui.config' , {
12
- 'tmplFilter' : { 'someopt' : 'foo' } ,
13
- 'wrapFilter' : { 'prefix' : 'cfoo-' , 'suffix' : '-cbar' } ,
14
- 'stylize' : { }
12
+ 'filterTmpl' : { 'somefilteropt' : 'foo' } ,
13
+ 'directiveTmpl' : { 'somedirectiveopt' : 'bar' }
15
14
} ) ;
16
15
17
16
beforeEach ( module ( 'ui.directives' ) ) ;
@@ -33,106 +32,36 @@ describe('uiTemplates', function() {
33
32
} ) ) ;
34
33
35
34
// very simple boilerplate setup of test for a custom filter
36
- describe ( 'tmplFilter ' , function ( ) {
35
+ describe ( 'filterTmpl should ' , function ( ) {
37
36
var tmpl ;
38
37
beforeEach ( function ( ) {
39
- tmpl = $filter ( 'tmpl ' ) ;
38
+ tmpl = $filter ( 'filterTmpl ' ) ;
40
39
} ) ;
41
40
42
- it ( 'prove exists when provided' , function ( ) {
41
+ it ( 'exist when provided' , function ( ) {
43
42
expect ( tmpl ) . toBeDefined ( ) ;
44
43
} ) ;
45
44
46
- it ( 'should return exactly what interesting thing (or not) the filter is doing to input' , function ( ) {
45
+ it ( 'return exactly what interesting thing the filter is doing to input' , function ( ) {
47
46
expect ( tmpl ( 'text' ) ) . toEqual ( 'text' ) ;
48
47
} ) ;
49
48
50
49
} ) ;
51
-
52
- // a test suite for a custom filter that does something
53
- describe ( 'wrapFilter' , function ( ) {
54
- var wrap ;
55
- beforeEach ( function ( ) {
56
- wrap = $filter ( 'wrap' ) ;
57
- } ) ;
58
-
59
- // this is a good test to always have make sure it has been properly defined, no reason to bother with the rest
60
- it ( 'prove exists when provided' , function ( ) {
61
- expect ( wrap ) . toBeDefined ( ) ;
62
- } ) ;
63
-
64
- it ( 'should return empty string for undefined/null/empty/missing values' , function ( ) {
65
- expect ( wrap ( '' ) ) . toEqual ( '' ) ;
66
- expect ( wrap ( null ) ) . toEqual ( '' ) ;
67
- expect ( wrap ( undefined ) ) . toEqual ( '' ) ;
68
- expect ( wrap ( ) ) . toEqual ( '' ) ;
69
- } ) ;
70
- it ( 'should properly wrap non-empty string without providing prefix/suffix' , function ( ) {
71
- expect ( wrap ( 'text' ) ) . toEqual ( 'cfoo-text-cbar' ) ;
72
- } ) ;
73
- it ( 'should properly prefix non-empty string with prefix' , function ( ) {
74
- expect ( wrap ( 'text' , 'foo-' ) ) . toEqual ( 'foo-text' ) ;
75
- } ) ;
76
- it ( 'should properly wrap non-empty string with both prefix and suffix' , function ( ) {
77
- expect ( wrap ( 'text' , 'foo-' , '-bar' ) ) . toEqual ( 'foo-text-bar' ) ;
78
- } ) ;
79
- } ) ;
80
50
} ) ;
81
51
82
52
describe ( 'directive tests' , function ( ) {
83
53
var element ;
84
- describe ( 'uiTmpl' , function ( ) {
85
- it ( 'should create an element if using Element-style' , function ( ) {
86
- var element = $compile ( '<ui-tmpl ng-model="a"></ui-tmpl>' ) ( $rootScope ) ;
87
- expect ( element ) . toBeDefined ( ) ;
88
- } ) ;
89
- it ( 'should render the models value in element' , function ( ) {
90
- var element = $compile ( '<div ui-tmpl ng-model="a"></div>' ) ( $rootScope ) ;
91
- expect ( element . text ( ) ) . toEqual ( '' ) ;
92
- $rootScope . a = 'foo' ;
93
- $rootScope . $digest ( ) ;
94
- expect ( element . text ( ) ) . toEqual ( 'foo' ) ;
95
- } ) ;
96
- } ) ;
97
-
98
- describe ( 'uiStylize' , function ( ) {
99
- it ( 'should create an element if using Element-style' , function ( ) {
100
- var element = $compile ( '<ui-stylize ng-model="a"></ui-stylize>' ) ( $rootScope ) ;
54
+ describe ( 'uiDirectiveTmpl should' , function ( ) {
55
+ it ( 'create an element if using element-style' , function ( ) {
56
+ var element = $compile ( '<ui-directive-tmpl ng-model="a"></ui-directive-tmpl>' ) ( $rootScope ) ;
101
57
expect ( element ) . toBeDefined ( ) ;
102
58
} ) ;
103
-
104
- it ( 'should render the alphabetic model value in element and assign ui-alpha class' , function ( ) {
105
- var element = $compile ( '<div ui-stylize ng-model="a"></div>' ) ( $rootScope ) ;
59
+ it ( 'render the models value in element' , function ( ) {
60
+ var element = $compile ( '<div ui-directive-tmpl ng-model="a"></div>' ) ( $rootScope ) ;
106
61
expect ( element . text ( ) ) . toEqual ( '' ) ;
107
62
$rootScope . a = 'foo' ;
108
63
$rootScope . $digest ( ) ;
109
64
expect ( element . text ( ) ) . toEqual ( 'foo' ) ;
110
- expect ( element . hasClass ( 'ui-alpha' ) ) . toBeTruthy ( 'ui-alpha' ) ;
111
- expect ( element . hasClass ( 'ui-numeric' ) ) . toBeFalsy ( 'ui-numeric' ) ;
112
- } ) ;
113
- it ( 'should handle integer model value in element and assign ui-numeric class' , function ( ) {
114
- var element = $compile ( '<div ui-stylize ng-model="a"></div>' ) ( $rootScope ) ;
115
- expect ( element . text ( ) ) . toEqual ( '' ) ;
116
- $rootScope . a = '123' ;
117
- $rootScope . $digest ( ) ;
118
- expect ( element . hasClass ( 'ui-numeric' ) ) . toBeTruthy ( 'ui-numeric' ) ;
119
- expect ( element . hasClass ( 'ui-alpha' ) ) . toBeFalsy ( 'ui-alpha' ) ;
120
- } ) ;
121
- it ( 'should handle float model value in element and assign ui-numeric class' , function ( ) {
122
- var element = $compile ( '<div ui-stylize ng-model="a"></div>' ) ( $rootScope ) ;
123
- expect ( element . text ( ) ) . toEqual ( '' ) ;
124
- $rootScope . a = '123.000123' ;
125
- $rootScope . $digest ( ) ;
126
- expect ( element . hasClass ( 'ui-numeric' ) ) . toBeTruthy ( 'ui-numeric' ) ;
127
- expect ( element . hasClass ( 'ui-alpha' ) ) . toBeFalsy ( 'ui-alpha' ) ;
128
- } ) ;
129
- it ( 'should handle mixed alpha/numeric model value in element and assign ui-alpha class' , function ( ) {
130
- var element = $compile ( '<div ui-stylize ng-model="a"></div>' ) ( $rootScope ) ;
131
- expect ( element . text ( ) ) . toEqual ( '' ) ;
132
- $rootScope . a = '123.000ABC' ;
133
- $rootScope . $digest ( ) ;
134
- expect ( element . hasClass ( 'ui-numeric' ) ) . toBeFalsy ( 'ui-numeric' ) ;
135
- expect ( element . hasClass ( 'ui-alpha' ) ) . toBeTruthy ( 'ui-alpha' ) ;
136
65
} ) ;
137
66
} ) ;
138
67
0 commit comments