Skip to content

Commit 8a06206

Browse files
committed
test(ai): wrap AI test suite in descriptive / indented block
this will help locate problems when problems happen in e2e, as it now follows the formatting convention of the rest of the test suite
1 parent 06dcae4 commit 8a06206

File tree

1 file changed

+32
-30
lines changed

1 file changed

+32
-30
lines changed

packages/ai/e2e/fetch.e2e.js

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -32,37 +32,39 @@ const fakeVertexAI = {
3232
globalThis.RNFB_VERTEXAI_EMULATOR_URL = true;
3333

3434
// It calls firebase functions emulator that mimics responses from VertexAI server
35-
describe('fetch requests()', function () {
36-
it('should fetch', async function () {
37-
const model = getGenerativeModel(fakeVertexAI, { model: 'gemini-1.5-flash' });
38-
const result = await model.generateContent("What is google's mission statement?");
39-
const text = result.response.text();
40-
// See vertexAI function emulator for response
41-
text.should.containEql(
42-
'Google\'s mission is to "organize the world\'s information and make it universally accessible and useful."',
43-
);
44-
});
35+
describe('ai()', function () {
36+
describe('fetch requests', function () {
37+
it('should fetch', async function () {
38+
const model = getGenerativeModel(fakeVertexAI, { model: 'gemini-1.5-flash' });
39+
const result = await model.generateContent("What is google's mission statement?");
40+
const text = result.response.text();
41+
// See vertexAI function emulator for response
42+
text.should.containEql(
43+
'Google\'s mission is to "organize the world\'s information and make it universally accessible and useful."',
44+
);
45+
});
4546

46-
it('should fetch stream', async function () {
47-
const model = getGenerativeModel(fakeVertexAI, { model: 'gemini-1.5-flash' });
48-
// See vertexAI function emulator for response
49-
const poem = [
50-
'The wind whispers secrets through the trees,',
51-
'Rustling leaves in a gentle breeze.',
52-
'Sunlight dances on the grass,',
53-
'A fleeting moment, sure to pass.',
54-
'Birdsong fills the air so bright,',
55-
'A symphony of pure delight.',
56-
'Time stands still, a peaceful pause,',
57-
"In nature's beauty, no flaws.",
58-
];
59-
const result = await model.generateContentStream('Write me a short poem');
47+
it('should fetch stream', async function () {
48+
const model = getGenerativeModel(fakeVertexAI, { model: 'gemini-1.5-flash' });
49+
// See vertexAI function emulator for response
50+
const poem = [
51+
'The wind whispers secrets through the trees,',
52+
'Rustling leaves in a gentle breeze.',
53+
'Sunlight dances on the grass,',
54+
'A fleeting moment, sure to pass.',
55+
'Birdsong fills the air so bright,',
56+
'A symphony of pure delight.',
57+
'Time stands still, a peaceful pause,',
58+
"In nature's beauty, no flaws.",
59+
];
60+
const result = await model.generateContentStream('Write me a short poem');
6061

61-
const text = [];
62-
for await (const chunk of result.stream) {
63-
const chunkText = chunk.text();
64-
text.push(chunkText);
65-
}
66-
text.should.deepEqual(poem);
62+
const text = [];
63+
for await (const chunk of result.stream) {
64+
const chunkText = chunk.text();
65+
text.push(chunkText);
66+
}
67+
text.should.deepEqual(poem);
68+
});
6769
});
6870
});

0 commit comments

Comments
 (0)