1
+ describe ( "formlyMaterial - chips type" , ( ) => {
2
+
3
+ //
4
+ // vars
5
+ //
6
+ let formlyConfig ;
7
+ let $compile ;
8
+ let $rootScope ;
9
+ let $scope ;
10
+ let element ;
11
+ let field ;
12
+ //
13
+ // helpers
14
+ //
15
+
16
+ function compile ( options ) {
17
+ $scope = $rootScope . $new ( ) ;
18
+ $scope . fields = [ angular . merge ( { } , {
19
+ key : 'testField' ,
20
+ type : 'chips' ,
21
+ templateOptions : {
22
+ label : 'test field' ,
23
+ placeholder : "+tags" ,
24
+ secondaryPlaceholder : "Add tag" ,
25
+ deleteButtonLabel : "Remove" ,
26
+ deleteHint : "Remove tag"
27
+ }
28
+ } , options ) ] ;
29
+
30
+ let form = $compile ( testUtils . formTemplate ) ( $scope ) ;
31
+
32
+ $scope . $digest ( ) ;
33
+ field = $scope . fields [ 0 ] ;
34
+ element = form . find ( '[ng-model]' ) ;
35
+ }
36
+
37
+ //
38
+ // tests
39
+ //
40
+
41
+ beforeEach ( ( ) => {
42
+ angular . module ( 'testApp' , [ 'angular-meteor' , 'formly' , 'formlyMaterial' ] ) ;
43
+ module ( 'testApp' ) ;
44
+
45
+ inject ( ( _$compile_ , _$rootScope_ , _formlyConfig_ ) => {
46
+ $compile = _$compile_ ;
47
+ $rootScope = _$rootScope_ ;
48
+ formlyConfig = _formlyConfig_ ;
49
+ } ) ;
50
+
51
+ const types = [ 'chips' ] ;
52
+
53
+ types . forEach ( ( type ) => {
54
+ testUtils . fixTypeTemplateUrl ( formlyConfig , type ) ;
55
+ } ) ;
56
+
57
+ compile ( ) ;
58
+ } ) ;
59
+
60
+ it ( 'should be md-chips element' , ( ) => {
61
+ expect ( element [ 0 ] . nodeName ) . toBe ( 'MD-CHIPS' ) ;
62
+ } ) ;
63
+
64
+ it ( 'should have placeholder' , ( ) => {
65
+ expect ( element . attr ( 'placeholder' ) ) . toBe ( field . templateOptions . placeholder ) ;
66
+ } ) ;
67
+
68
+ it ( 'should have secondary placeholder' , ( ) => {
69
+ expect ( element . attr ( 'secondary-placeholder' ) ) . toBe ( field . templateOptions . secondaryPlaceholder ) ;
70
+ } ) ;
71
+
72
+ it ( 'should have delete button label' , ( ) => {
73
+ expect ( element . attr ( 'delete-button-label' ) ) . toBe ( field . templateOptions . deleteButtonLabel ) ;
74
+ } ) ;
75
+
76
+ it ( 'should have delete hint' , ( ) => {
77
+ expect ( element . attr ( 'delete-hint' ) ) . toBe ( field . templateOptions . deleteHint ) ;
78
+ } ) ;
79
+
80
+ } ) ;
0 commit comments