Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
frederikprijck committed Sep 10, 2023
1 parent bfeb62a commit c044fca
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion test/management/grants.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import nock from 'nock';

const API_URL = 'https://tenant.auth0.com/api/v2';

import { GrantsManager, ManagementClient } from '../../src/index.js';
import { GrantsManager, ManagementClient, RequiredError } from '../../src/index.js';

describe('GrantsManager', () => {
let grants: GrantsManager;
Expand Down Expand Up @@ -148,5 +148,30 @@ describe('GrantsManager', () => {
done();
});
});

describe('#deleteByUserId', () => {
const user_id = '5';
let request: nock.Scope;

beforeEach(() => {
request = nock(API_URL).delete(`/grants/?user_id=${user_id}`).reply(200, {});
});

it('should return a promise when no callback is given', (done) => {
grants.deleteByUserId({ user_id }).then(done.bind(null, null));
});

it(`should perform a DELETE request to /grants/${id}`, (done) => {
grants.deleteByUserId({ user_id }).then(() => {
expect(request.isDone()).toBe(true);

done();
});
});

it('should return an error when client_id is not sent', async () => {
await expect(grants.deleteByUserId({} as any)).rejects.toThrowError(RequiredError);
});
});
});
});

0 comments on commit c044fca

Please sign in to comment.