This commit is contained in:
syuilo 2023-02-02 18:08:34 +09:00
parent 2cc98226ca
commit 07f885fea8

View File

@ -50,6 +50,15 @@ describe('RoleService', () => {
.then(x => rolesRepository.findOneByOrFail(x.identifiers[0])); .then(x => rolesRepository.findOneByOrFail(x.identifiers[0]));
} }
async function assign(roleId: Role['id'], userId: User['id']) {
await roleAssignmentsRepository.insert({
id: genAid(new Date()),
createdAt: new Date(),
roleId,
userId,
});
}
beforeEach(async () => { beforeEach(async () => {
app = await Test.createTestingModule({ app = await Test.createTestingModule({
imports: [ imports: [
@ -131,12 +140,7 @@ describe('RoleService', () => {
}, },
}, },
}); });
await roleAssignmentsRepository.insert({ await assign(role.id, user.id);
id: 'a',
createdAt: new Date(),
roleId: role.id,
userId: user.id,
});
metaService.fetch.mockResolvedValue({ metaService.fetch.mockResolvedValue({
policies: { policies: {
canManageCustomEmojis: false, canManageCustomEmojis: false,
@ -170,18 +174,8 @@ describe('RoleService', () => {
}, },
}, },
}); });
await roleAssignmentsRepository.insert({ await assign(role1.id, user.id);
id: genAid(new Date()), await assign(role2.id, user.id);
createdAt: new Date(),
roleId: role1.id,
userId: user.id,
});
await roleAssignmentsRepository.insert({
id: genAid(new Date()),
createdAt: new Date(),
roleId: role2.id,
userId: user.id,
});
metaService.fetch.mockResolvedValue({ metaService.fetch.mockResolvedValue({
policies: { policies: {
driveCapacityMb: 50, driveCapacityMb: 50,