Skip to content

Commit

Permalink
fix: add test, clarify comments
Browse files Browse the repository at this point in the history
  • Loading branch information
WillieRuemmele committed Mar 25, 2021
1 parent 62d367b commit 8d5679e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,15 +214,12 @@ export class Connection extends JSForceConnection {
/**
* Will deploy a recently validated deploy request
*
* @param options.id = the id of the deploy to quickly validate
* @param options.id = the deploy ID that's been validated already from a previous checkOnly deploy request
* @param options.rest = a boolean whether or not to use the REST API
*/
public async deployRecentValidation(options: recentValidationOptions): Promise<JsonCollection> {
if (options.rest) {
const url = `${this.instanceUrl.replace(
/\/$/,
''
)}/services/data/v${this.getApiVersion()}/metadata/deployRequest`;
const url = `${this.baseUrl()}/metadata/deployRequest`;
const messageBody = JSON.stringify({
validatedDeployRequestId: options.id,
});
Expand All @@ -234,6 +231,7 @@ export class Connection extends JSForceConnection {
const requestOptions = { headers: 'json' };
return this.request(requestInfo, requestOptions);
} else {
// the _invoke is private in jsforce, we can call the SOAP deployRecentValidation like this
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
// @ts-ignore
return this.metadata['_invoke']('deployRecentValidation', {
Expand Down
11 changes: 11 additions & 0 deletions test/unit/connectionTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,17 @@ describe('Connection', () => {
await conn.deployRecentValidation({ id: '0Afxx00000000lWCAQ', rest: true });
expect(requestStub.callCount).to.equal(1);
});

it('deployRecentValidation() should call jsforce for SOAP', async () => {
const conn = await Connection.create({ authInfo: fromStub(testAuthInfo) });
conn.instanceUrl = 'myNewInstance@salesforce.com';
// @ts-ignore private method
const requestStub = $$.SANDBOX.stub(conn.metadata, '_invoke');

await conn.deployRecentValidation({ id: '0Afxx00000000lWCAQ' });
expect(requestStub.callCount).to.equal(1);
expect(requestStub.args[0][0]).to.equal('deployRecentValidation');
});
});

it('singleRecordQuery returns single-record result properly', async () => {
Expand Down

0 comments on commit 8d5679e

Please sign in to comment.