Devendra174's picture
Upload folder using huggingface_hub
1e92f2d verified
raw
history blame
1.39 kB
import {
createSFFVResponse,
createSingleSearchResponse,
} from '../createAPIResponse';
describe('createSingleSearchResponse', () => {
test('calculates nbHits from hits', () => {
expect(
createSingleSearchResponse({
hits: Array.from({ length: 100 }),
})
).toEqual(
expect.objectContaining({
nbHits: 100,
})
);
});
test('calculates nbPages from nbHits and hitsPerPage', () => {
expect(
createSingleSearchResponse({
nbHits: 100,
hitsPerPage: 20,
})
).toEqual(
expect.objectContaining({
nbPages: 5,
})
);
});
test('calculates nbPages from default nbHits and hitsPerPage', () => {
expect(createSingleSearchResponse({})).toEqual(
expect.objectContaining({
nbPages: 0,
})
);
});
test('allows to override params', () => {
expect(
createSingleSearchResponse({
query: 'custom query',
processingTimeMS: 10,
})
).toEqual(
expect.objectContaining({
query: 'custom query',
processingTimeMS: 10,
})
);
});
});
describe('createSFFVResponse', () => {
test('allows to override params', () => {
expect(
createSFFVResponse({
processingTimeMS: 10,
})
).toEqual(
expect.objectContaining({
processingTimeMS: 10,
})
);
});
});