Skip to content

Commit

Permalink
Add test for setting the external_id parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Carroll authored and matthewcarroll committed Nov 18, 2024
1 parent b77e0f7 commit fce82d4
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/management/jobs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,33 @@ describe('JobsManager', () => {
});
});

it('should set the `external_id` parameter correctly', (done) => {
nock.cleanAll();
let boundary: string | null = null;
const external_id = 'some_job_correlation_id';

const request = nock(API_URL)
.matchHeader('Content-Type', (header) => {
boundary = `--${header.match(/boundary=([^\n]*)/)?.[1]}`;

return true;
})
.post('/jobs/users-imports', (body) => {
const parts = extractParts(body, boundary);

expect(parts.external_id).toBe(external_id);

return true;
})
.reply(200, {});

jobs.importUsers(Object.assign({}, data, { external_id })).then(() => {
expect(request.isDone()).toBe(true);

done();
});
});

it('should include the token in the Authorization header', (done) => {
nock.cleanAll();

Expand Down

0 comments on commit fce82d4

Please sign in to comment.