Skip to content

Commit

Permalink
test: add update account test and fix it
Browse files Browse the repository at this point in the history
  • Loading branch information
ycmjason committed Oct 17, 2024
1 parent d239145 commit 60d0108
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
24 changes: 24 additions & 0 deletions integration/account.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,27 @@ it("fetch should return an account object", async () => {
contact: emails.map((email) => `mailto:${email}`),
});
});

it("should update account contacts correctly", async () => {
const client = await AcmeClient.init(PEBBLE_DIRECTORY_URL);

const emails = [generateRandomEmail(), generateRandomEmail()];

const acmeAccount = await client.createAccount({
emails,
});

expect(await acmeAccount.fetch()).toMatchObject({
status: "valid",
contact: emails.map((email) => `mailto:${email}`),
});

const newEmails = [
generateRandomEmail(),
];
const updatedAccountObject = await acmeAccount.update({ emails: newEmails });

expect(updatedAccountObject.contact).toEqual(
newEmails.map((email) => `mailto:${email}`),
);
});
2 changes: 1 addition & 1 deletion src/AcmeAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export class AcmeAccount {
): Promise<AcmeAccountObjectSnapshot> {
const response = await this.jwsFetch(this.url, {
payload: {
contacts: emailsToAccountContacts(emails),
contact: emailsToAccountContacts(emails),
},
});

Expand Down
File renamed without changes.

0 comments on commit 60d0108

Please sign in to comment.