Skip to content

Commit

Permalink
test: fix failed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
louis-menlo committed Jan 14, 2025
1 parent ca55df3 commit a63322b
Showing 1 changed file with 17 additions and 28 deletions.
45 changes: 17 additions & 28 deletions web/utils/modelEngine.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,40 +25,29 @@ describe('isLocalEngine', () => {

it('should return false if engine is not found', () => {
mockGet.mockReturnValue(null)
const result = isLocalEngine('nonexistentEngine')
const result = isLocalEngine(
{
'llama-cpp': [],
} as any,
'nonexistentEngine'
)
expect(result).toBe(false)
})

it('should return true if engine is an instance of LocalOAIEngine', () => {
const mockEngineObj = {
__proto__: {
constructor: {
__proto__: {
name: LocalOAIEngine.name,
it('should return true if this is a local engine', () => {
mockGet.mockReturnValue(null)
const result = isLocalEngine(
{
'llama-cpp': [
{
type: 'local',
},
},
},
}
mockGet.mockReturnValue(mockEngineObj)
const result = isLocalEngine('localEngine')
],
} as any,
'llama-cpp'
)
expect(result).toBe(true)
})

it('should return false if engine is not an instance of LocalOAIEngine', () => {
const mockEngineObj = {
__proto__: {
constructor: {
__proto__: {
name: 'SomeOtherEngine',
},
},
},
}
mockGet.mockReturnValue(mockEngineObj)
const result = isLocalEngine('someOtherEngine')
expect(result).toBe(false)
})

jest.mock('@janhq/core', () => ({
...jest.requireActual('@janhq/core'),
EngineManager: {
Expand Down

0 comments on commit a63322b

Please sign in to comment.