@@ -93,6 +93,41 @@ describe('getCacheDirectoryPath', () => {
93
93
. then ( data => expect ( data ) . toEqual ( expectedResult ) ) ;
94
94
} ) ;
95
95
96
+ it ( 'should return path to the cache folder if one command return empty str' , async ( ) => {
97
+ //Arrange
98
+ getExecOutputSpy . mockImplementationOnce ( ( commandLine : string ) => {
99
+ return new Promise < exec . ExecOutput > ( resolve => {
100
+ resolve ( { exitCode : 0 , stdout : 'path/to/cache/folder' , stderr : '' } ) ;
101
+ } ) ;
102
+ } ) ;
103
+
104
+ getExecOutputSpy . mockImplementationOnce ( ( commandLine : string ) => {
105
+ return new Promise < exec . ExecOutput > ( resolve => {
106
+ resolve ( { exitCode : 0 , stdout : '' , stderr : '' } ) ;
107
+ } ) ;
108
+ } ) ;
109
+
110
+ const expectedResult = [ 'path/to/cache/folder' ] ;
111
+
112
+ //Act + Assert
113
+ return cacheUtils
114
+ . getCacheDirectoryPath ( validPackageManager )
115
+ . then ( data => expect ( data ) . toEqual ( expectedResult ) ) ;
116
+ } ) ;
117
+
118
+ it ( 'should throw if the both commands return empty str' , async ( ) => {
119
+ getExecOutputSpy . mockImplementation ( ( commandLine : string ) => {
120
+ return new Promise < exec . ExecOutput > ( resolve => {
121
+ resolve ( { exitCode : 10 , stdout : '' , stderr : '' } ) ;
122
+ } ) ;
123
+ } ) ;
124
+
125
+ //Act + Assert
126
+ expect ( async ( ) => {
127
+ await cacheUtils . getCacheDirectoryPath ( validPackageManager ) ;
128
+ } ) . rejects . toThrow ( ) ;
129
+ } ) ;
130
+
96
131
it ( 'should throw if the specified package name is invalid' , async ( ) => {
97
132
getExecOutputSpy . mockImplementation ( ( commandLine : string ) => {
98
133
return new Promise < exec . ExecOutput > ( resolve => {
0 commit comments