feat: add integration tests for getRecordsByIds method
This commit is contained in:
@@ -101,4 +101,44 @@ describe('getRecordsByIds', function () {
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
it('should return a 400 error if too many record ids are passed', async function () {
|
||||
const client = new OnspringClient(baseURL, apiKey);
|
||||
const recordIds = new Array(101).fill(1);
|
||||
const request = new GetRecordsRequest(1, recordIds);
|
||||
const response = await client.getRecordsByIds(request);
|
||||
|
||||
expect(response.statusCode).to.equal(400);
|
||||
expect(response.isSuccessful).to.be.false;
|
||||
expect(response.message).to.not.be.null.and.not.be.undefined;
|
||||
expect(response.data).to.be.null;
|
||||
});
|
||||
|
||||
it('should return a 401 error if the api key is invalid', async function () {
|
||||
const client = new OnspringClient(baseURL, 'invalid');
|
||||
const request = new GetRecordsRequest(1, [1]);
|
||||
const response = await client.getRecordsByIds(request);
|
||||
|
||||
expect(response.statusCode).to.equal(401);
|
||||
expect(response.isSuccessful).to.be.false;
|
||||
expect(response.message).to.be.undefined;
|
||||
expect(response.data).to.be.null;
|
||||
});
|
||||
|
||||
it('should return a 403 error if the user does not have access to the app', async function () {
|
||||
const client = new OnspringClient(baseURL, apiKey);
|
||||
|
||||
if (process.env.TEST_APP_ID_NO_ACCESS === undefined) {
|
||||
expect.fail('TEST_APP_ID_NO_ACCESS is not defined');
|
||||
}
|
||||
|
||||
const appId = parseInt(process.env.TEST_APP_ID_NO_ACCESS);
|
||||
const request = new GetRecordsRequest(appId, [1]);
|
||||
const response = await client.getRecordsByIds(request);
|
||||
|
||||
expect(response.statusCode).to.equal(403);
|
||||
expect(response.isSuccessful).to.be.false;
|
||||
expect(response.message).to.not.be.null.and.not.be.undefined;
|
||||
expect(response.data).to.be.null;
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user