Skip to content

Commit 02113db

Browse files
committed
feat: added tests
1 parent 9f9656e commit 02113db

File tree

5 files changed

+435
-8
lines changed

5 files changed

+435
-8
lines changed

src/types/chat/ChatModel.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,4 @@ export type ChatModel =
44
| 'jamba-large-1.6-2025-03'
55
| 'jamba-mini-1.6-2025-03'
66
| 'jamba-large-1.6'
7-
| 'jamba-mini-1.6'
8-
| 'jamba-1.5-mini'
9-
| 'jamba-1.5-large';
7+
| 'jamba-mini-1.6';

tests/unittests/resources/chat/completions.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ describe('Completions', () => {
3030

3131
it('should create a non-streaming completion when stream is false', async () => {
3232
const body: Models.ChatCompletionCreateParamsNonStreaming = {
33-
model: "jamba-1.5-mini",
33+
model: "jamba-mini",
3434
messages: [{role: "user", content: "Hello"}],
3535
};
3636
const options: Models.RequestOptions = { headers: { 'Authorization': `Bearer ${dummyAPIKey}` } };
@@ -58,7 +58,7 @@ describe('Completions', () => {
5858
});
5959

6060
it('should create a streaming completion when stream is true', async () => {
61-
const body: Models.ChatCompletionCreateParamsStreaming = { model: "jamba-1.5-mini", messages: [{role: "user", content: "Hello"}], stream: true };
61+
const body: Models.ChatCompletionCreateParamsStreaming = { model: "jamba-mini", messages: [{role: "user", content: "Hello"}], stream: true };
6262
const options: Models.RequestOptions = { headers: { 'Authorization': `Bearer ${dummyAPIKey}` } };
6363
const expectedStream: Models.ChatCompletionChunk = {
6464
id: "test-id",
@@ -85,7 +85,7 @@ describe('Completions', () => {
8585
});
8686

8787
it('should use default options when options parameter is omitted', async () => {
88-
const body: Models.ChatCompletionCreateParamsNonStreaming = { model: "jamba-1.5-mini", messages: [{role: "user", content: "Hello"}], stream: false };
88+
const body: Models.ChatCompletionCreateParamsNonStreaming = { model: "jamba-mini", messages: [{role: "user", content: "Hello"}], stream: false };
8989
const expectedResponse: Models.ChatCompletionResponse = {
9090
id: "test-id",
9191
usage: {
@@ -108,7 +108,7 @@ describe('Completions', () => {
108108
});
109109

110110
it('should handle errors thrown by the API client', async () => {
111-
const body: Models.ChatCompletionCreateParamsNonStreaming = { model: "jamba-1.5-mini", messages: [{role: "user", content: "Hello"}], stream: false };
111+
const body: Models.ChatCompletionCreateParamsNonStreaming = { model: "jamba-mini", messages: [{role: "user", content: "Hello"}], stream: false };
112112
const error = new AI21Error();
113113

114114
mockClient.post.mockRejectedValue(error);
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import { Maestro } from '../../../../src/resources/maestro/maestro';
2+
import { Beta } from '../../../../src/resources/maestro/beta';
3+
import { Runs } from '../../../../src/resources/maestro/runs';
4+
import { APIClient } from '../../../../src/APIClient';
5+
6+
class MockAPIClient extends APIClient {
7+
public post = jest.fn();
8+
public get = jest.fn();
9+
}
10+
11+
describe('Maestro', () => {
12+
let maestro: Maestro;
13+
let mockClient: MockAPIClient;
14+
15+
beforeEach(() => {
16+
mockClient = new MockAPIClient({
17+
baseURL: 'https://api.example.com',
18+
maxRetries: 3,
19+
timeout: 5000,
20+
});
21+
22+
maestro = new Maestro(mockClient);
23+
});
24+
25+
afterEach(() => {
26+
jest.clearAllMocks();
27+
});
28+
29+
it('should initialize with a Runs instance', () => {
30+
expect(maestro).toBeInstanceOf(Maestro);
31+
expect(maestro.runs).toBeInstanceOf(Runs);
32+
});
33+
34+
it('should share the same client with runs', () => {
35+
expect(maestro.runs['client']).toBe(mockClient);
36+
});
37+
});
38+
39+
describe('Beta', () => {
40+
let beta: Beta;
41+
let mockClient: MockAPIClient;
42+
43+
beforeEach(() => {
44+
mockClient = new MockAPIClient({
45+
baseURL: 'https://api.example.com',
46+
maxRetries: 3,
47+
timeout: 5000,
48+
});
49+
50+
beta = new Beta(mockClient);
51+
});
52+
53+
afterEach(() => {
54+
jest.clearAllMocks();
55+
});
56+
57+
it('should initialize with a Maestro instance', () => {
58+
expect(beta).toBeInstanceOf(Beta);
59+
expect(beta.maestro).toBeInstanceOf(Maestro);
60+
});
61+
62+
it('should have access to runs through maestro', () => {
63+
expect(beta.maestro.runs).toBeInstanceOf(Runs);
64+
});
65+
66+
it('should share the same client through the hierarchy', () => {
67+
expect(beta.maestro['client']).toBe(mockClient);
68+
expect(beta.maestro.runs['client']).toBe(mockClient);
69+
});
70+
});

0 commit comments

Comments
 (0)