Last active
October 29, 2024 21:53
-
-
Save Akifcan/740cad78ca55ffdaa6b27fed75599fff to your computer and use it in GitHub Desktop.
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
describe('ProductService', () => { | |
let service: ProductService | |
let servicMock: Partial<ProductService> | |
beforeEach(async () => { | |
const module: TestingModule = await Test.createTestingModule({ | |
imports: [AppModule], | |
}).compile() | |
service = module.get<ProductService>(ProductService) | |
servicMock = { | |
createProductDescription: jest.fn().mockResolvedValue( | |
id: 'msg_01TioynCv5SbDGXsLLUnUPTL', | |
type: 'message', | |
role: 'assistant', | |
model: 'claude-3-5-sonnet-20240620', | |
content: [ | |
{ | |
type: 'text', | |
text: 'AN AMAZING DESCRIPTION' | |
} | |
], | |
stop_reason: 'end_turn', | |
stop_sequence: null, | |
usage: { input_tokens: 1844, output_tokens: 611 } | |
}), | |
} | |
}) | |
it('should be defined', () => { | |
expect(service).toBeDefined() | |
}) | |
it('should create a product description', () => { | |
const response = (await servicMock.createProductDescription('Nike shoe'))() | |
expect(response).toHaveProperty('id') | |
expect(response).toHaveProperty('type') | |
expect(response).toHaveProperty('role') | |
expect(response).toHaveProperty('model') | |
expect(response).toHaveProperty('content') | |
expect(Array.isArray(response)).toBe(true) | |
expect(response.content[0]).toHaveProperty('type') | |
expect(response.content[0]).toHaveProperty('text') | |
expect(response).toHaveProperty('stop_reason') | |
expect(response).toHaveProperty('stop_sequence') | |
expect(response).toHaveProperty('usage') | |
expect(response.usage).toHaveProperty('input_tokens') | |
expect(response.usage).toHaveProperty('output_tokens') | |
// ------ diğer testler.... | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment