@@ -4,6 +4,7 @@ import os from 'node:os';
44import { afterEach , beforeEach , describe , it } from 'node:test' ;
55import sinon from 'sinon' ;
66
7+ import type { InstallationQuery } from '../index' ;
78import { InstallProvider } from '../index' ;
89import { FileInstallationStore } from './index' ;
910
@@ -79,11 +80,11 @@ describe('FileInstallationStore', async () => {
7980 beforeEach ( ( ) => {
8081 // Note that these sinon stubs affect the `os` package behaviors
8182 // in the tests in this file
82- fsMakeDirSync = sinon . stub ( fs , 'mkdirSync' ) . returns ( { } as any ) ;
83- fsWriteFileSync = sinon . stub ( fs , 'writeFileSync' ) . returns ( undefined as any ) ;
83+ fsMakeDirSync = ( sinon . stub ( fs , 'mkdirSync' ) as sinon . SinonStub ) . returns ( undefined ) ;
84+ fsWriteFileSync = ( sinon . stub ( fs , 'writeFileSync' ) as sinon . SinonStub ) . returns ( undefined ) ;
8485 fsReadFileSync = sinon . stub ( fs , 'readFileSync' ) . returns ( Buffer . from ( JSON . stringify ( storedInstallation ) ) ) ;
85- fsUnlinkSync = sinon . stub ( fs , 'unlinkSync' ) . returns ( undefined as any ) ;
86- fsReaddirSync = sinon . stub ( fs , 'readdirSync' ) . returns ( [ 'app-latest' , 'user-userId-latest' ] as any ) ;
86+ fsUnlinkSync = ( sinon . stub ( fs , 'unlinkSync' ) as sinon . SinonStub ) . returns ( undefined ) ;
87+ fsReaddirSync = ( sinon . stub ( fs , 'readdirSync' ) as sinon . SinonStub ) . returns ( [ 'app-latest' , 'user-userId-latest' ] ) ;
8788 } ) ;
8889
8990 afterEach ( ( ) => {
@@ -117,7 +118,8 @@ describe('FileInstallationStore', async () => {
117118 try {
118119 await installationStore . storeInstallation ( storedInstallation ) ;
119120 assert . fail ( 'An exception should be thrown' ) ;
120- } catch ( e : any ) {
121+ } catch ( e : unknown ) {
122+ assert . ok ( e instanceof Error ) ;
121123 assert . strictEqual (
122124 e . message ,
123125 'Failed to save installation to FileInstallationStore (error: Error: The original error message)' ,
@@ -167,7 +169,8 @@ describe('FileInstallationStore', async () => {
167169 teamId : 'T111' ,
168170 } ) ;
169171 assert . fail ( `An exception should be thrown ${ JSON . stringify ( res ) } ` ) ;
170- } catch ( e : any ) {
172+ } catch ( e : unknown ) {
173+ assert . ok ( e instanceof Error ) ;
171174 assert . strictEqual (
172175 e . message ,
173176 'No installation data found (enterprise_id: E999, team_id: T111, user_id: undefined)' ,
@@ -232,13 +235,13 @@ describe('FileInstallationStore', async () => {
232235 } ,
233236 } ;
234237 const installationStore = {
235- fetchInstallation : ( _ : any ) => {
238+ fetchInstallation : ( _ : InstallationQuery < boolean > ) => {
236239 return new Promise ( ( resolve ) => {
237240 resolve ( storedInstallation ) ;
238241 } ) ;
239242 } ,
240243 storeInstallation : ( ) => { } ,
241- deleteInstallation : ( _ : any ) => { } ,
244+ deleteInstallation : ( _ : InstallationQuery < boolean > ) => { } ,
242245 } ;
243246 const installer = new InstallProvider ( { clientId, clientSecret, stateSecret, installationStore } ) ;
244247 const authorizeResult = await installer . authorize ( { teamId : 'T111' } ) ;
@@ -270,13 +273,13 @@ describe('FileInstallationStore', async () => {
270273 user : null ,
271274 } ;
272275 const installationStore = {
273- fetchInstallation : ( _ : any ) => {
276+ fetchInstallation : ( _ : InstallationQuery < boolean > ) => {
274277 return new Promise ( ( resolve ) => {
275278 resolve ( storedInstallation ) ;
276279 } ) ;
277280 } ,
278281 storeInstallation : ( ) => { } ,
279- deleteInstallation : ( _ : any ) => { } ,
282+ deleteInstallation : ( _ : InstallationQuery < boolean > ) => { } ,
280283 } ;
281284 const installer = new InstallProvider ( { clientId, clientSecret, stateSecret, installationStore } ) ;
282285 const authorizeResult = await installer . authorize ( { teamId : 'T111' } ) ;
0 commit comments