Skip to content

Commit

Permalink
adjust api test
Browse files Browse the repository at this point in the history
  • Loading branch information
mrikallab committed Sep 26, 2023
1 parent 6d18c6e commit 3a879ec
Showing 1 changed file with 49 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1202,5 +1202,54 @@ describe('UserLoginMigrationController (API)', () => {
expect(response.status).toEqual(HttpStatus.FORBIDDEN);
});
});

describe('when no user has migrate', () => {
const setup = async () => {
const sourceSystem: SystemEntity = systemFactory.withLdapConfig().buildWithId({ alias: 'SourceSystem' });
const targetSystem: SystemEntity = systemFactory.withOauthConfig().buildWithId({ alias: 'SANIS' });
const school: SchoolEntity = schoolFactory.buildWithId({
systems: [sourceSystem],
officialSchoolNumber: '12345',
});
const userLoginMigration: UserLoginMigrationEntity = userLoginMigrationFactory.buildWithId({
school,
targetSystem,
sourceSystem,
startedAt: new Date(2023, 1, 4),
});

const user: User = userFactory.buildWithId();

const { adminAccount, adminUser } = UserAndAccountTestFactory.buildAdmin({ school }, [
Permission.USER_LOGIN_MIGRATION_ADMIN,
]);

await em.persistAndFlush([
sourceSystem,
targetSystem,
school,
adminAccount,
adminUser,
userLoginMigration,
user,
]);
em.clear();

const loggedInClient = await testApiClient.login(adminAccount);

return {
loggedInClient,
userLoginMigration,
};
};

it('should return nothing', async () => {
const { loggedInClient } = await setup();

const response: Response = await loggedInClient.post('/close');

expect(response.body).toEqual({});
});
});
});
});

0 comments on commit 3a879ec

Please sign in to comment.