Skip to content

Commit 8c77408

Browse files
russellwheatleydackers86
authored andcommitted
Apply suggestions from code review
Co-authored-by: Darren Ackers <[email protected]>
1 parent 0963b9c commit 8c77408

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

packages/ai/__tests__/api.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ const fakeAI: AI = {
4040
location: 'us-central1',
4141
};
4242

43-
describe('Top level API', () => {
44-
it('getGenerativeModel throws if no model is provided', () => {
43+
describe('getGenerativeModel()', () => {
44+
it('should throw an error if no model is provided', () => {
4545
try {
4646
getGenerativeModel(fakeAI, {} as ModelParams);
4747
} catch (e) {
@@ -70,7 +70,7 @@ describe('Top level API', () => {
7070
}
7171
});
7272

73-
it('getGenerativeModel throws if no projectId is provided', () => {
73+
it('should throw an error if no projectId is provided', () => {
7474
const fakeVertexNoProject = {
7575
...fakeAI,
7676
app: { options: { apiKey: 'my-key' } },
@@ -87,7 +87,7 @@ describe('Top level API', () => {
8787
}
8888
});
8989

90-
it('getGenerativeModel throws if no appId is provided', () => {
90+
it('should throw an error if no appId is provided', () => {
9191
const fakeVertexNoProject = {
9292
...fakeAI,
9393
app: { options: { apiKey: 'my-key', projectId: 'my-projectid' } },
@@ -104,7 +104,7 @@ describe('Top level API', () => {
104104
}
105105
});
106106

107-
it('getGenerativeModel gets a GenerativeModel', () => {
107+
it('should return an instance of GenerativeModel', () => {
108108
const genModel = getGenerativeModel(fakeAI, { model: 'my-model' });
109109
expect(genModel).toBeInstanceOf(GenerativeModel);
110110
expect(genModel.model).toBe('publishers/google/models/my-model');

packages/ai/__tests__/backend.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,26 @@ import { DEFAULT_LOCATION } from '../lib/constants';
2121

2222
describe('Backend', () => {
2323
describe('GoogleAIBackend', () => {
24-
it('sets backendType to GOOGLE_AI', () => {
24+
it('should set backendType to GOOGLE_AI', () => {
2525
const backend = new GoogleAIBackend();
2626
expect(backend.backendType).toBe(BackendType.GOOGLE_AI);
2727
});
2828
});
2929

3030
describe('VertexAIBackend', () => {
31-
it('set backendType to VERTEX_AI', () => {
31+
it('should set backendType to VERTEX_AI', () => {
3232
const backend = new VertexAIBackend();
3333
expect(backend.backendType).toBe(BackendType.VERTEX_AI);
3434
expect(backend.location).toBe(DEFAULT_LOCATION);
3535
});
3636

37-
it('sets custom location', () => {
37+
it('should set a custom location', () => {
3838
const backend = new VertexAIBackend('test-location');
3939
expect(backend.backendType).toBe(BackendType.VERTEX_AI);
4040
expect(backend.location).toBe('test-location');
4141
});
4242

43-
it('uses default location if location is empty string', () => {
43+
it('should use a default location if location is empty string', () => {
4444
const backend = new VertexAIBackend('');
4545
expect(backend.backendType).toBe(BackendType.VERTEX_AI);
4646
expect(backend.location).toBe(DEFAULT_LOCATION);

packages/vertexai/__tests__/backwards-compatbility.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,34 +47,34 @@ const fakeAI: AI = {
4747

4848
const fakeVertexAI: VertexAI = fakeAI;
4949

50-
describe('backwards-compatible types', function () {
51-
it('AI is backwards compatible with VertexAI', function () {
50+
describe('VertexAI backward compatibility', function () {
51+
it('should allow VertexAI to be assignable to AI', function () {
5252
assertAssignable<VertexAI, AI>();
5353
});
5454

55-
it('AIError is backwards compatible with VertexAIError', function () {
55+
it('should allow VertexAIError to extend AIError, function () {
5656
assertAssignable<typeof VertexAIError, typeof AIError>();
5757
const err = new VertexAIError(VertexAIErrorCode.ERROR, '');
5858
expect(err).toBeInstanceOf(AIError);
5959
expect(err).toBeInstanceOf(VertexAIError);
6060
});
6161

62-
it('AIErrorCode is backwards compatible with VertexAIErrorCode', () => {
62+
it('should allow VertexAIErrorCode to be assignable to AIErrorCode', () => {
6363
assertAssignable<VertexAIErrorCode, AIErrorCode>();
6464
const errCode = AIErrorCode.ERROR;
6565
expect(errCode).toBe(VertexAIErrorCode.ERROR);
6666
});
6767

68-
it('AIModel is backwards compatible with VertexAIModel', () => {
68+
it('should allow VertexAIModel to extend AIModel', () => {
6969
assertAssignable<typeof VertexAIModel, typeof AIModel>();
7070

7171
const model = new GenerativeModel(fakeAI, { model: 'model-name' });
7272
expect(model).toBeInstanceOf(AIModel);
7373
expect(model).toBeInstanceOf(VertexAIModel);
7474
});
7575

76-
describe('backward-compatible functions', () => {
77-
it('getGenerativeModel', () => {
76+
describe('VertexAI functions', () => {
77+
it('should return a VertexAIModel assignable to AIModel from getGenerativeModel()l', () => {
7878
const model = getGenerativeModel(fakeVertexAI, { model: 'model-name' });
7979
expect(model).toBeInstanceOf(AIModel);
8080
expect(model).toBeInstanceOf(VertexAIModel);

0 commit comments

Comments
 (0)