Просмотр исходного кода

add test for updating to existing name

kaori 4 лет назад
Родитель
Сommit
bd14f151d7
1 измененных файлов с 7 добавлено и 2 удалено
  1. 7 2
      packages/app/test/integration/service/v5.user-groups.test.ts

+ 7 - 2
packages/app/test/integration/service/v5.user-groups.test.ts

@@ -59,17 +59,22 @@ describe('UserGroupService', () => {
      * Update UserGroup
      * Update UserGroup
      */
      */
   test('Can update user group basic info', async() => {
   test('Can update user group basic info', async() => {
-    const userGroup = await UserGroup.findOne({ name: 'v5_group1' });
+    const userGroup = await UserGroup.findOne({ _id: groupId1 });
 
 
     const newGroupName = 'v5_group1_new';
     const newGroupName = 'v5_group1_new';
     const newGroupDescription = 'description1_new';
     const newGroupDescription = 'description1_new';
     const newParentId = groupId2;
     const newParentId = groupId2;
 
 
-    const updatedUserGroup = await crowi.userGroupService.updateGroup(userGroup.id, newGroupName, newGroupDescription, newParentId);
+    const updatedUserGroup = await crowi.userGroupService.updateGroup(userGroup._id, newGroupName, newGroupDescription, newParentId);
 
 
     expect(updatedUserGroup.name).toBe(newGroupName);
     expect(updatedUserGroup.name).toBe(newGroupName);
     expect(updatedUserGroup.description).toBe(newGroupDescription);
     expect(updatedUserGroup.description).toBe(newGroupDescription);
     expect(updatedUserGroup.parent).toStrictEqual(newParentId);
     expect(updatedUserGroup.parent).toStrictEqual(newParentId);
   });
   });
 
 
+  test('Cannot update to existing group name', async() => {
+    const userGroup = await UserGroup.findOne({ _id: groupId1 });
+    await expect(crowi.userGroupService.updateGroup(userGroup._id, 'v5_group2')).rejects.toThrow('The group name is already taken');
+  });
+
 });
 });