-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- fix: added tests for tool backend project
- Loading branch information
1 parent
5386845
commit 603030e
Showing
4 changed files
with
51 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* eslint-disable */ | ||
export default { | ||
displayName: '@shinkai_protocol/shinkai-tool-download-page', | ||
displayName: '@shinkai_protocol/shinkai-tools-backend', | ||
preset: '../../jest.preset.js', | ||
coverageDirectory: '../../coverage/apps/shinkai-tool-download-page' | ||
coverageDirectory: '../../coverage/apps/shinkai-tools-backend', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { fastify } from './index'; | ||
|
||
test('GET /health', async () => { | ||
const response = await fastify.inject({ | ||
method: 'GET', | ||
url: '/health', | ||
}); | ||
expect(response.json().status).toBe('ok'); | ||
}); | ||
|
||
test('GET /tool/definition', async () => { | ||
const response = await fastify.inject({ | ||
method: 'POST', | ||
url: '/tool/run', | ||
body: { | ||
code: ` | ||
class BaseTool { | ||
constructor(config) { | ||
this.config = config; | ||
} | ||
setConfig(value) { | ||
this.config = value; | ||
return this.config; | ||
} | ||
getConfig() { | ||
return this.config; | ||
} | ||
} | ||
class Tool extends BaseTool { | ||
constructor(config) { | ||
super(config); | ||
} | ||
async run() { | ||
const result = await new Promise((resolve) => { | ||
setTimeout(() => { | ||
resolve(100); | ||
}, 200); | ||
}); | ||
return { data: result }; | ||
} | ||
} | ||
globalThis.tool = { Tool }; | ||
`, | ||
}, | ||
}); | ||
expect(response.json().data).toBe(100); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters