@@ -716,6 +716,94 @@ describe('DetailsFieldsComponent', () => {
716716 expect ( component . entryForm . value . project_name ) . toBe ( 'name' ) ;
717717 } ) ;
718718
719+ it ( 'should display a warning message when trying to save time entry of internal app without required fields' , ( ) => {
720+ component . entryForm . setValue ( {
721+ project_id : 'p1' ,
722+ project_name : 'ioet inc.' ,
723+ activity_id : 'a1' ,
724+ uri : '' ,
725+ start_date : '2020-02-05' ,
726+ end_date : '2020-02-05' ,
727+ start_hour : '00:00' ,
728+ end_hour : '00:01' ,
729+ description : '' ,
730+ technology : '' ,
731+ } ) ;
732+ spyOn ( toastrServiceStub , 'warning' ) ;
733+
734+ component . onSubmit ( ) ;
735+ expect ( toastrServiceStub . warning ) . toHaveBeenCalled ( ) ;
736+
737+ } ) ;
738+
739+
740+ it ( 'should not display a warning message when trying to save time entry of internal app with uri and save' , ( ) => {
741+ component . entryForm . setValue ( {
742+ project_id : 'p1' ,
743+ project_name : 'ioet inc.' ,
744+ activity_id : 'a1' ,
745+ uri : 'TTL-666' ,
746+ start_date : '2020-02-05' ,
747+ end_date : '2020-02-05' ,
748+ start_hour : '00:00' ,
749+ end_hour : '00:01' ,
750+ description : '' ,
751+ technology : '' ,
752+ } ) ;
753+ spyOn ( toastrServiceStub , 'warning' ) ;
754+ spyOn ( component . saveEntry , 'emit' ) ;
755+
756+ component . onSubmit ( ) ;
757+ expect ( toastrServiceStub . warning ) . not . toHaveBeenCalled ( ) ;
758+
759+ expect ( component . saveEntry . emit ) . toHaveBeenCalled ( ) ;
760+ } ) ;
761+
762+
763+ it ( 'should not display a warning message when trying to save time entry of external customer without required fields and save' , ( ) => {
764+ component . entryForm . setValue ( {
765+ project_id : 'p1' ,
766+ project_name : 'customer inc. - proj' ,
767+ activity_id : 'a1' ,
768+ uri : '' ,
769+ start_date : '2020-02-05' ,
770+ end_date : '2020-02-05' ,
771+ start_hour : '00:00' ,
772+ end_hour : '00:01' ,
773+ description : '' ,
774+ technology : '' ,
775+ } ) ;
776+ spyOn ( toastrServiceStub , 'warning' ) ;
777+ spyOn ( component . saveEntry , 'emit' ) ;
778+
779+ component . onSubmit ( ) ;
780+ expect ( toastrServiceStub . warning ) . not . toHaveBeenCalled ( ) ;
781+
782+ expect ( component . saveEntry . emit ) . toHaveBeenCalled ( ) ;
783+ } ) ;
784+
785+ it ( 'should not display a warning message when trying to save time entry of internal app with description and save' , ( ) => {
786+ component . entryForm . setValue ( {
787+ project_id : 'p1' ,
788+ project_name : 'ioet inc. - proj' ,
789+ activity_id : 'a1' ,
790+ uri : '' ,
791+ start_date : '2020-02-05' ,
792+ end_date : '2020-02-05' ,
793+ start_hour : '00:00' ,
794+ end_hour : '00:01' ,
795+ description : 'asdf' ,
796+ technology : '' ,
797+ } ) ;
798+ spyOn ( toastrServiceStub , 'warning' ) ;
799+ spyOn ( component . saveEntry , 'emit' ) ;
800+
801+ component . onSubmit ( ) ;
802+ expect ( toastrServiceStub . warning ) . not . toHaveBeenCalled ( ) ;
803+
804+ expect ( component . saveEntry . emit ) . toHaveBeenCalled ( ) ;
805+ } ) ;
806+
719807 /*
720808 TODO As part of https://github.com/ioet/time-tracker-ui/issues/424 a new parameter was added to the details-field-component,
721809 and now these couple of tests are failing. A solution to this error might be generate a Test Wrapper Component. More details here:
0 commit comments