first commit
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,119 @@
|
||||
import * as getMany from '../../../actions/file/getMany.operation';
|
||||
import * as transport from '../../../transport';
|
||||
import { createMockExecuteFunction } from '../helpers';
|
||||
|
||||
const baseNodeParameters = {
|
||||
resource: 'file',
|
||||
operation: 'getMany',
|
||||
sessionId: 'test-session-123',
|
||||
returnAll: true,
|
||||
outputSingleItem: true,
|
||||
};
|
||||
|
||||
const mockFilesResponse = {
|
||||
data: {
|
||||
files: [
|
||||
{
|
||||
id: 'file-123',
|
||||
name: 'document1.pdf',
|
||||
size: 12345,
|
||||
contentType: 'application/pdf',
|
||||
createdAt: '2023-06-15T10:30:00Z',
|
||||
},
|
||||
{
|
||||
id: 'file-456',
|
||||
name: 'image1.jpg',
|
||||
size: 54321,
|
||||
contentType: 'image/jpeg',
|
||||
createdAt: '2023-06-16T11:45:00Z',
|
||||
},
|
||||
],
|
||||
pagination: {
|
||||
hasMore: false,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const mockPaginatedResponse = {
|
||||
data: {
|
||||
files: [mockFilesResponse.data.files[0]],
|
||||
pagination: {
|
||||
hasMore: true,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
jest.mock('../../../transport', () => {
|
||||
const originalModule = jest.requireActual<typeof transport>('../../../transport');
|
||||
return {
|
||||
...originalModule,
|
||||
apiRequest: jest.fn(),
|
||||
};
|
||||
});
|
||||
|
||||
describe('Test Airtop, get many files operation', () => {
|
||||
afterAll(() => {
|
||||
jest.unmock('../../../transport');
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
it('should get all files successfully', async () => {
|
||||
const apiRequestMock = transport.apiRequest as jest.Mock;
|
||||
apiRequestMock.mockResolvedValueOnce(mockFilesResponse);
|
||||
|
||||
const result = await getMany.execute.call(createMockExecuteFunction(baseNodeParameters), 0);
|
||||
|
||||
expect(apiRequestMock).toHaveBeenCalledWith(
|
||||
'GET',
|
||||
'/files',
|
||||
{},
|
||||
{
|
||||
limit: 100,
|
||||
offset: 0,
|
||||
sessionIds: '',
|
||||
},
|
||||
);
|
||||
|
||||
expect(result).toEqual([
|
||||
{
|
||||
json: {
|
||||
...mockFilesResponse,
|
||||
},
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('should handle limited results', async () => {
|
||||
const apiRequestMock = transport.apiRequest as jest.Mock;
|
||||
apiRequestMock.mockResolvedValueOnce(mockPaginatedResponse);
|
||||
|
||||
const nodeParameters = {
|
||||
...baseNodeParameters,
|
||||
returnAll: false,
|
||||
limit: 1,
|
||||
};
|
||||
|
||||
const result = await getMany.execute.call(createMockExecuteFunction(nodeParameters), 0);
|
||||
|
||||
expect(apiRequestMock).toHaveBeenCalledWith(
|
||||
'GET',
|
||||
'/files',
|
||||
{},
|
||||
{
|
||||
limit: 1,
|
||||
sessionIds: '',
|
||||
},
|
||||
);
|
||||
|
||||
expect(result).toEqual([
|
||||
{
|
||||
json: {
|
||||
...mockPaginatedResponse,
|
||||
},
|
||||
},
|
||||
]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user