@@ -12,7 +12,7 @@ import {
1212 createPullRequestParams
1313} from '../../../../src/api-sdk/github/utils' ;
1414import { MOCK_REPO_URL , MOCK_BASE_SHA , MOCK_BLOB_SHA , MOCK_TREE_SHA , MOCK_COMMIT_SHA , MOCK_BRANCH_NAME , MOCK_PATH , MOCK_COMMIT_MESSAGE , MOCK_PR_TITLE , MOCK_PR_BODY } from '../../../mock/text.mock' ;
15- import { MOCK_POST_BLOB , MOCK_INVALID_SHA_RESPONSE , MOCK_POST_BRANCH , MOCK_POST_TREE , MOCK_POST_COMMIT , MOCK_POST_PR } from '../../../mock/data.mock' ;
15+ import { MOCK_POST_BLOB , MOCK_INVALID_SHA_RESPONSE , MOCK_POST_BRANCH , MOCK_POST_TREE , MOCK_POST_COMMIT , MOCK_POST_PR , MOCK_API_ERROR } from '../../../mock/data.mock' ;
1616
1717describe ( 'Github utils test suites' , ( ) => {
1818
@@ -30,8 +30,9 @@ describe('Github utils test suites', () => {
3030 } ) ;
3131
3232 test ( 'extractBaseShaHelper should return response if resource does not exist' , ( ) => {
33- const result = extractBaseShaHelper ( MOCK_INVALID_SHA_RESPONSE ) ;
34- expect ( result ) . toEqual ( MOCK_INVALID_SHA_RESPONSE ) ;
33+ jest . spyOn ( global , 'Error' ) . mockImplementationOnce ( ( ) => MOCK_API_ERROR ) ;
34+
35+ expect ( ( ) => extractBaseShaHelper ( MOCK_INVALID_SHA_RESPONSE ) ) . toThrowError ( MOCK_API_ERROR ) ;
3536 } ) ;
3637
3738 test ( 'extractShaHelper should return sha if it exists' , ( ) => {
@@ -44,8 +45,9 @@ describe('Github utils test suites', () => {
4445 } ) ;
4546
4647 test ( 'extractShaHelper should return response if sha does not exist' , ( ) => {
47- const result = extractShaHelper ( MOCK_INVALID_SHA_RESPONSE ) ;
48- expect ( result ) . toEqual ( MOCK_INVALID_SHA_RESPONSE ) ;
48+ jest . spyOn ( global , 'Error' ) . mockImplementationOnce ( ( ) => MOCK_API_ERROR ) ;
49+
50+ expect ( ( ) => extractShaHelper ( MOCK_INVALID_SHA_RESPONSE ) ) . toThrowError ( MOCK_API_ERROR ) ;
4951 } ) ;
5052
5153 test ( 'getShaParams should return the correct sha URL' , ( ) => {
@@ -87,7 +89,7 @@ describe('Github utils test suites', () => {
8789 } ) ;
8890
8991 test ( 'createPullRequestParams should return the correct PR URL and body' , ( ) => {
90- const { prUrl, prPostbody } = createPullRequestParams ( MOCK_REPO_URL , MOCK_PR_TITLE , MOCK_PR_BODY , MOCK_BRANCH_NAME , 'main' ) ;
92+ const { prUrl, prPostbody } = createPullRequestParams ( MOCK_REPO_URL , MOCK_PR_TITLE , MOCK_PR_BODY , MOCK_BRANCH_NAME ) ;
9193 expect ( prUrl ) . toBe ( `${ MOCK_REPO_URL } /pulls` ) ;
9294 expect ( prPostbody ) . toEqual ( MOCK_POST_PR ) ;
9395 } ) ;
0 commit comments