From fce82d487439daa587e2d0a949ffbbee97a11d00 Mon Sep 17 00:00:00 2001 From: Matthew Carroll Date: Tue, 10 Sep 2024 18:54:58 -0400 Subject: [PATCH] Add test for setting the external_id parameter --- test/management/jobs.test.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/test/management/jobs.test.ts b/test/management/jobs.test.ts index 69da7e272..7dba0d555 100644 --- a/test/management/jobs.test.ts +++ b/test/management/jobs.test.ts @@ -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();