@@ -13,6 +13,7 @@ describe('DetailsFieldsComponent', () => {
1313 let fixture : ComponentFixture < DetailsFieldsComponent > ;
1414 let store : MockStore < TechnologyState > ;
1515 let mockTechnologySelector ;
16+ let length ;
1617
1718 const state = {
1819 technologyList : { items : [ { name : 'java' } ] } ,
@@ -53,12 +54,6 @@ describe('DetailsFieldsComponent', () => {
5354 expect ( component ) . toBeTruthy ( ) ;
5455 } ) ;
5556
56- it ( 'should emit saveEntry event' , ( ) => {
57- spyOn ( component . saveEntry , 'emit' ) ;
58- component . onSubmit ( ) ;
59- expect ( component . saveEntry . emit ) . toHaveBeenCalledWith ( initialData ) ;
60- } ) ;
61-
6257 it ( 'should emit ngOnChange without data' , ( ) => {
6358 component . entryToEdit = null ;
6459 component . ngOnChanges ( ) ;
@@ -71,12 +66,22 @@ describe('DetailsFieldsComponent', () => {
7166 expect ( component . entryForm . value ) . toEqual ( newData ) ;
7267 } ) ;
7368
74- it ( 'should dispatch LoadTechnology action #getTechnologies' , ( ) => {
69+ it ( 'should dispatch FindTechnology action #getTechnologies' , ( ) => {
7570 const value = 'java' ;
7671 spyOn ( store , 'dispatch' ) ;
72+ length = value . length ;
7773 component . getTechnologies ( value ) ;
7874
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 ) ) ;
8085 } ) ;
8186
8287 it ( 'should add a new tag #setTechnology' , ( ) => {
@@ -102,4 +107,10 @@ describe('DetailsFieldsComponent', () => {
102107 component . removeTag ( index ) ;
103108 expect ( component . selectedTechnology . length ) . toBe ( 1 ) ;
104109 } ) ;
110+
111+ it ( 'should emit saveEntry event' , ( ) => {
112+ spyOn ( component . saveEntry , 'emit' ) ;
113+ component . onSubmit ( ) ;
114+ expect ( component . saveEntry . emit ) . toHaveBeenCalledWith ( initialData ) ;
115+ } ) ;
105116} ) ;
0 commit comments