Skip to content

Commit f851d7e

Browse files
committed
fix(tests): update specs after invite/vacancy repository changes
- invite.repository: add null guard on raw.sender/raw.user in sendForUser (same as getMy/getByProject) - vacancy.repository.spec: update getForProject mock to return ApiPagination<Vacancy> instead of plain array to match the adapter contract change
1 parent 4822795 commit f851d7e

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

projects/social_platform/src/app/infrastructure/repository/invite/invite.repository.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ export class InviteRepository implements InviteRepositoryPort {
6060
return this.inviteAdapter.sendForUser(userId, projectId, role, specialization).pipe(
6161
map(raw => {
6262
const invite = plainToInstance(Invite, raw);
63-
invite.sender = userFromRaw(raw.sender);
64-
invite.user = userFromRaw(raw.user);
63+
if (raw.sender) invite.sender = userFromRaw(raw.sender);
64+
if (raw.user) invite.user = userFromRaw(raw.user);
6565
return invite;
6666
}),
6767
);

projects/social_platform/src/app/infrastructure/repository/vacancy/vacancy.repository.spec.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ describe("VacancyRepository", () => {
4040
it("getForProject делегирует и мапит в Vacancy[]", () =>
4141
new Promise<void>(done => {
4242
setup();
43-
adapter.getForProject.mockReturnValue(of([{ id: 1 }] as Vacancy[]));
43+
adapter.getForProject.mockReturnValue(
44+
of({ count: 1, results: [{ id: 1 }], next: null, previous: null }),
45+
);
4446

4547
repository.getForProject(10, 0, 42, "3+", "remote", "full", "100", "js").subscribe(res => {
4648
expect(adapter.getForProject).toHaveBeenCalledExactlyOnceWith(
@@ -162,7 +164,7 @@ describe("VacancyRepository", () => {
162164
adapter.getForProject.mockImplementation(() =>
163165
defer(() => {
164166
fetches++;
165-
return of([{ id: 7 }] as Vacancy[]);
167+
return of({ count: 1, results: [{ id: 7 }], next: null, previous: null });
166168
}),
167169
);
168170

0 commit comments

Comments
 (0)