1
- describe ( 'select' , function ( ) {
2
- it ( '' , function ( ) {
3
- } ) ;
4
- } ) ;
1
+ describe ( 'ui-select tests' , function ( ) {
5
2
3
+ var scope , $rootScope , $compile ;
4
+
5
+ beforeEach ( module ( 'ui.select' ) ) ;
6
+ beforeEach ( module ( '../src/select2/choices.tpl.html' ) ) ;
7
+ beforeEach ( module ( '../src/select2/match.tpl.html' ) ) ;
8
+ beforeEach ( module ( '../src/select2/select.tpl.html' ) ) ;
9
+ beforeEach ( inject ( function ( _$rootScope_ , _$compile_ ) {
10
+ $rootScope = _$rootScope_ ;
11
+ scope = $rootScope . $new ( ) ;
12
+ $compile = _$compile_ ;
13
+ scope . matches = [
14
+ { "id" :
1 , "name" :
"Wladimir Coka" , "email" :
"[email protected] " } ,
15
+ { "id" :
2 , "name" :
"Samantha Smith" , "email" :
"[email protected] " } ,
16
+ { "id" :
3 , "name" :
"Estefanía Smith" , "email" :
"[email protected] " } ,
17
+ { "id" :
4 , "name" :
"Natasha Jones" , "email" :
"[email protected] " } ,
18
+ { "id" :
5 , "name" :
"Nicole Smith" , "email" :
"[email protected] " }
19
+ ] ;
20
+ } ) ) ;
21
+
22
+ //Utility functions
23
+ var prepareUiSelectEl = function ( inputTpl ) {
24
+ var el = $compile ( angular . element ( inputTpl ) ) ( scope ) ;
25
+ scope . $digest ( ) ;
26
+ return el ;
27
+ } ;
28
+
29
+ var uiSelectElInstance1 = function ( inputTpl ) {
30
+ var element = prepareUiSelectEl (
31
+ '<ui-select ng-model="selection" style="width:300px"> \
32
+ <match placeholder="Pick one...">{{$select.selected.name}}</match> \
33
+ <choices data="matches | filter : $select.search"> \
34
+ <div ng-bind-html="trustAsHtml((item.name | highlight:$select.search))"/></div> \
35
+ <div> {{item.email}} </div> \
36
+ </choices> \
37
+ </ui-select> \
38
+ ' ) ;
39
+ return element ;
40
+ } ;
41
+
42
+ it ( 'should compile basic ui-select-* elements ' , function ( ) {
43
+
44
+ var el = uiSelectElInstance1 ( ) ;
45
+
46
+ var searchEl = $ ( el ) . find ( '.ui-select-search' ) ;
47
+ expect ( searchEl . length ) . toEqual ( 1 ) ;
48
+
49
+ var matchEl = $ ( el ) . find ( '.ui-select-match' ) ;
50
+ expect ( matchEl . length ) . toEqual ( 1 ) ;
51
+
52
+ var choicesContentEl = $ ( el ) . find ( '.ui-select-choices-content' ) ;
53
+ expect ( choicesContentEl . length ) . toEqual ( 1 ) ;
54
+
55
+ var choicesContainerEl = $ ( el ) . find ( '.ui-select-choices' ) ;
56
+ expect ( choicesContainerEl . length ) . toEqual ( 1 ) ;
57
+
58
+ var choicesElems = $ ( el ) . find ( '.ui-select-choices-row' ) ;
59
+ expect ( choicesElems . length ) . toEqual ( 5 ) ;
60
+
61
+ } ) ;
62
+
63
+ } ) ;
0 commit comments