@@ -56,4 +56,64 @@ describe('getDiff', () => {
5656 expect ( result . steps [ 0 ] . content ) . to . include ( 'modified content' ) ;
5757 expect ( result . steps [ 0 ] . content ) . to . include ( 'initial content' ) ;
5858 } ) ;
59+
60+ it ( 'should get diff between commits with no changes' , async ( ) => {
61+ const action = new Action (
62+ '1234567890' ,
63+ 'push' ,
64+ 'POST' ,
65+ 1234567890 ,
66+ 'test/repo'
67+ ) ;
68+ action . proxyGitPath = __dirname ; // Temp dir parent path
69+ action . repoName = 'temp-test-repo' ;
70+ action . commitFrom = 'HEAD~1' ;
71+ action . commitTo = 'HEAD' ;
72+ action . commitData = [
73+ { parent : '0000000000000000000000000000000000000000' }
74+ ] ;
75+
76+ const result = await exec ( { } , action ) ;
77+
78+ expect ( result . steps [ 0 ] . error ) . to . be . false ;
79+ expect ( result . steps [ 0 ] . content ) . to . include ( 'initial content' ) ;
80+ } ) ;
81+
82+ it ( 'should throw an error if no commit data is provided' , async ( ) => {
83+ const action = new Action (
84+ '1234567890' ,
85+ 'push' ,
86+ 'POST' ,
87+ 1234567890 ,
88+ 'test/repo'
89+ ) ;
90+ action . proxyGitPath = __dirname ; // Temp dir parent path
91+ action . repoName = 'temp-test-repo' ;
92+ action . commitFrom = 'HEAD~1' ;
93+ action . commitTo = 'HEAD' ;
94+ action . commitData = [ ] ;
95+
96+ const result = await exec ( { } , action ) ;
97+ expect ( result . steps [ 0 ] . error ) . to . be . true ;
98+ expect ( result . steps [ 0 ] . errorMessage ) . to . contain ( 'No commit data found' ) ;
99+ } ) ;
100+
101+ it ( 'should throw an error if no commit data is provided' , async ( ) => {
102+ const action = new Action (
103+ '1234567890' ,
104+ 'push' ,
105+ 'POST' ,
106+ 1234567890 ,
107+ 'test/repo'
108+ ) ;
109+ action . proxyGitPath = __dirname ; // Temp dir parent path
110+ action . repoName = 'temp-test-repo' ;
111+ action . commitFrom = 'HEAD~1' ;
112+ action . commitTo = 'HEAD' ;
113+ action . commitData = undefined ;
114+
115+ const result = await exec ( { } , action ) ;
116+ expect ( result . steps [ 0 ] . error ) . to . be . true ;
117+ expect ( result . steps [ 0 ] . errorMessage ) . to . contain ( 'No commit data found' ) ;
118+ } ) ;
59119} ) ;
0 commit comments