Futa Arai 2 лет назад
Родитель
Сommit
c9bc0ece09
1 измененных файлов с 5 добавлено и 7 удалено
  1. 5 7
      apps/app/test/integration/service/ldap-user-group-sync.test.ts

+ 5 - 7
apps/app/test/integration/service/ldap-user-group-sync.test.ts

@@ -1,9 +1,12 @@
+import ldap, { Client } from 'ldapjs';
+
 import LdapUserGroupSyncService from '../../../src/features/external-user-group/server/service/ldap-user-group-sync';
 import { configManager } from '../../../src/server/service/config-manager';
 import LdapService from '../../../src/server/service/ldap';
 import PassportService from '../../../src/server/service/passport';
 import { getInstance } from '../setup-crowi';
 
+
 describe('LdapUserGroupSyncService.generateExternalUserGroupTrees', () => {
   let crowi;
   let ldapGroupSyncService: LdapUserGroupSyncService;
@@ -22,13 +25,7 @@ describe('LdapUserGroupSyncService.generateExternalUserGroupTrees', () => {
   jest.mock('../../../src/server/service/ldap');
   const mockBind = jest.spyOn(LdapService.prototype, 'bind');
   const mockLdapSearch = jest.spyOn(LdapService.prototype, 'search');
-
-  // mock LdapService constructor
-  const OriginalLdapService = { ...LdapService };
-  const mockConstructor = jest.fn(function(username, password) {
-    OriginalLdapService.constructor.call(this, 'Mocked LdapServer');
-  });
-  LdapService.prototype.constructor = mockConstructor;
+  const mockLdapCreateClient = jest.spyOn(ldap, 'createClient');
 
   beforeAll(async() => {
     crowi = await getInstance();
@@ -40,6 +37,7 @@ describe('LdapUserGroupSyncService.generateExternalUserGroupTrees', () => {
     mockBind.mockImplementation(() => {
       return Promise.resolve();
     });
+    mockLdapCreateClient.mockImplementation(() => { return {} as Client });
   });
 
   describe('When there is no circular reference in group tree', () => {