@@ -13,6 +13,7 @@ describe('DetailsFieldsComponent', () => {
13
13
let fixture : ComponentFixture < DetailsFieldsComponent > ;
14
14
let store : MockStore < TechnologyState > ;
15
15
let mockTechnologySelector ;
16
+ let length ;
16
17
17
18
const state = {
18
19
technologyList : { items : [ { name : 'java' } ] } ,
@@ -53,12 +54,6 @@ describe('DetailsFieldsComponent', () => {
53
54
expect ( component ) . toBeTruthy ( ) ;
54
55
} ) ;
55
56
56
- it ( 'should emit saveEntry event' , ( ) => {
57
- spyOn ( component . saveEntry , 'emit' ) ;
58
- component . onSubmit ( ) ;
59
- expect ( component . saveEntry . emit ) . toHaveBeenCalledWith ( initialData ) ;
60
- } ) ;
61
-
62
57
it ( 'should emit ngOnChange without data' , ( ) => {
63
58
component . entryToEdit = null ;
64
59
component . ngOnChanges ( ) ;
@@ -71,12 +66,22 @@ describe('DetailsFieldsComponent', () => {
71
66
expect ( component . entryForm . value ) . toEqual ( newData ) ;
72
67
} ) ;
73
68
74
- it ( 'should dispatch LoadTechnology action #getTechnologies' , ( ) => {
69
+ it ( 'should dispatch FindTechnology action #getTechnologies' , ( ) => {
75
70
const value = 'java' ;
76
71
spyOn ( store , 'dispatch' ) ;
72
+ length = value . length ;
77
73
component . getTechnologies ( value ) ;
78
74
79
- expect ( store . dispatch ) . toHaveBeenCalledWith ( new actions . LoadTechnology ( value ) ) ;
75
+ expect ( store . dispatch ) . toHaveBeenCalledWith ( new actions . FindTechnology ( value ) ) ;
76
+ } ) ;
77
+
78
+ it ( 'should NOT dispatch FindTechnology action #getTechnologies' , ( ) => {
79
+ const value = 'j' ;
80
+ spyOn ( store , 'dispatch' ) ;
81
+ length = value . length ;
82
+ component . getTechnologies ( value ) ;
83
+
84
+ expect ( store . dispatch ) . not . toHaveBeenCalledWith ( new actions . FindTechnology ( value ) ) ;
80
85
} ) ;
81
86
82
87
it ( 'should add a new tag #setTechnology' , ( ) => {
@@ -102,4 +107,10 @@ describe('DetailsFieldsComponent', () => {
102
107
component . removeTag ( index ) ;
103
108
expect ( component . selectedTechnology . length ) . toBe ( 1 ) ;
104
109
} ) ;
110
+
111
+ it ( 'should emit saveEntry event' , ( ) => {
112
+ spyOn ( component . saveEntry , 'emit' ) ;
113
+ component . onSubmit ( ) ;
114
+ expect ( component . saveEntry . emit ) . toHaveBeenCalledWith ( initialData ) ;
115
+ } ) ;
105
116
} ) ;
0 commit comments