File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -92,4 +92,42 @@ describe('customModule_CS.js', () => {
9292 expect ( aModuleSpy ) . toHaveBeenCalledTimes ( 1 ) ;
9393 } ) ;
9494 } ) ;
95+ describe ( 'test saveRecord' , ( ) => {
96+ const Record = new record . Record ( ) ;
97+ describe ( 'test errors' , ( ) => {
98+ const ErrorSpy = jest . spyOn ( log , 'error' ) ;
99+ test ( 'Should not throw any errors' , ( ) => {
100+ const ExecSaveRecord = customModule_CS . saveRecord ( {
101+ currentRecord : Record ,
102+ } ) ;
103+ expect (
104+ jest . fn ( ( ) => {
105+ ExecSaveRecord ;
106+ } )
107+ ) . not . toThrow ( Error ) ;
108+ expect ( ExecSaveRecord ) . toBeTruthy ( ) ;
109+ expect ( ErrorSpy ) . toHaveBeenCalledTimes ( 0 ) ;
110+ } ) ;
111+ test ( 'Should catch errors' , ( ) => {
112+ const ExecSaveRecord = customModule_CS . saveRecord ( ) ;
113+ expect (
114+ jest . fn ( ( ) => {
115+ ExecSaveRecord ;
116+ } )
117+ ) . not . toThrow ( Error ) ;
118+ expect ( ExecSaveRecord ) . toBeTruthy ( ) ;
119+ expect ( ErrorSpy ) . toHaveBeenCalledTimes ( 1 ) ;
120+ } ) ;
121+ test ( "Doesn't allow save if no currentRecord property found" , ( ) => {
122+ const ExecSaveRecord = customModule_CS . saveRecord ( { } ) ;
123+ expect (
124+ jest . fn ( ( ) => {
125+ ExecSaveRecord ;
126+ } )
127+ ) . not . toThrow ( Error ) ;
128+ expect ( ExecSaveRecord ) . toBeFalsy ( ) ;
129+ expect ( ErrorSpy ) . toHaveBeenCalledTimes ( 0 ) ;
130+ } ) ;
131+ } ) ;
132+ } ) ;
95133} ) ;
You can’t perform that action at this time.
0 commit comments