Skip to content

Commit

Permalink
test: ensure rejected response is caught
Browse files Browse the repository at this point in the history
  • Loading branch information
iFergal committed Jan 7, 2025
1 parent 373e1d0 commit 4b1aa6d
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test/app/aiding.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,16 @@ describe('Aiding', () => {
assert.deepEqual(lastCall.body.salty.transferable, true);
});

it('Should throw error if fetch call fails when creating identifier', async () => {
const error = new Error(`Fail ${randomUUID()}`);
client.fetch.mockRejectedValue(error);
await expect(
client
.identifiers()
.create('aid1', { bran: '0123456789abcdefghijk' })
).rejects.toThrow(error);
});

it('Can rotate salty identifier', async () => {
const aid1 = await createMockIdentifierState('aid1', bran, {});
client.fetch.mockResolvedValueOnce(Response.json(aid1));
Expand Down Expand Up @@ -346,6 +356,14 @@ describe('Aiding', () => {
});
});

it('Should throw error if fetch call fails when adding end role', async () => {
const error = new Error(`Fail ${randomUUID()}`);
client.fetch.mockRejectedValue(error);
await expect(
client.identifiers().addEndRole('aid1', 'agent')
).rejects.toThrow(error);
});

it('Can get members', async () => {
client.fetch.mockResolvedValue(Response.json({}));
await client.identifiers().members('aid1');
Expand Down

0 comments on commit 4b1aa6d

Please sign in to comment.