Skip to content

Commit

Permalink
EW.1019 Add saveAll to account-idm-service
Browse files Browse the repository at this point in the history
  • Loading branch information
SimoneRadtke-Cap committed Dec 17, 2024
1 parent 470329c commit 4a163ae
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,37 @@ describe('AccountIdmService', () => {
});
});

describe('saveAll', () => {
describe('when save multiple accounts', () => {
const setup = () => {
const mockAccountSaves = [
{
id: mockIdmAccountRefId,
username: 'testUserName1',
userId: 'userId1',
systemId: 'systemId1',
} as AccountSave,
{
id: undefined,
username: 'testUserName2',
userId: 'userId2',
systemId: 'systemId2',
} as AccountSave,
];

return { mockAccountSaves };
};

it('should save all accounts', async () => {
const { mockAccountSaves } = setup();

const ret = await accountIdmService.saveAll(mockAccountSaves);

expect(ret).toHaveLength(mockAccountSaves.length);
});
});
});

describe('updateUsername', () => {
describe('when update Username', () => {
const setup = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,11 @@ export class AccountServiceIdm extends AbstractAccountService {
return this.accountIdmToDoMapper.mapToDo(updatedAccount);
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
public saveAll(accountSaves: AccountSave[]): Promise<Account[]> {
throw new Error('Method not implemented.');
public async saveAll(accountSaves: AccountSave[]): Promise<Account[]> {
const savePromises = accountSaves.map((accountSave) => this.save(accountSave));
const savedAccounts = await Promise.all(savePromises);

return savedAccounts;
}

private async updateAccount(idmAccountId: string, idmAccount: IdmAccountUpdate, password?: string): Promise<string> {
Expand Down

0 comments on commit 4a163ae

Please sign in to comment.