From fdcdcf93722e2c7fdc415958bc48374f0134838d Mon Sep 17 00:00:00 2001
From: rhenck <richard.henck@iqb.hu-berlin.de>
Date: Thu, 22 Sep 2022 14:07:35 +0200
Subject: [PATCH] [editor] Fix IDService unit tests

---
 .../src/app/services/id-manager.spec.ts       | 42 ++++++++++---------
 1 file changed, 22 insertions(+), 20 deletions(-)

diff --git a/projects/editor/src/app/services/id-manager.spec.ts b/projects/editor/src/app/services/id-manager.spec.ts
index 9ecc52976..5b758f637 100644
--- a/projects/editor/src/app/services/id-manager.spec.ts
+++ b/projects/editor/src/app/services/id-manager.spec.ts
@@ -1,43 +1,45 @@
-import { IDManager } from 'common/util/id-manager';
+import { IDService } from 'editor/src/app/services/id.service';
+import { TestBed } from '@angular/core/testing';
 
 describe('IDService', () => {
-  let manager: IDManager;
+  let idService: IDService;
 
   beforeEach(() => {
-    manager = IDManager.getInstance();
-    manager.reset();
+    TestBed.configureTestingModule({});
+    idService = TestBed.inject(IDService);
+    idService.reset();
   });
 
   it('getNewID should fail on empty string param', () => {
-    expect(() => { manager.getNewID(''); }).toThrow(Error('ID-Service: No type given!'));
+    expect(() => { idService.getNewID(''); }).toThrow(Error('ID-Service: No type given!'));
   });
 
   it('getNewID should return first ID', () => {
-    expect(manager.getNewID('text')).toBe('text_1');
+    expect(idService.getNewID('text')).toBe('text_1');
   });
 
   it('getNewID should return different IDs - counting up', () => {
-    manager.getNewID('text');
-    expect(manager.getNewID('text')).toBe('text_2');
+    idService.getNewID('text');
+    expect(idService.getNewID('text')).toBe('text_2');
   });
 
-  it('manager should return next id when one is already taken', () => {
-    manager.addID('text_1');
-    expect(manager.getNewID('text')).toBe('text_2');
+  it('idService should return next id when one is already taken', () => {
+    idService.addID('text_1');
+    expect(idService.getNewID('text')).toBe('text_2');
   });
 
   it('isIdAvailable should return false when id is already taken', () => {
-    expect(manager.isIdAvailable('text_1')).toBe(true);
-    manager.addID('text_1');
-    expect(manager.isIdAvailable('text_1')).toBe(false);
-    expect(manager.isIdAvailable('text_2')).toBe(true);
+    expect(idService.isIdAvailable('text_1')).toBe(true);
+    idService.addID('text_1');
+    expect(idService.isIdAvailable('text_1')).toBe(false);
+    expect(idService.isIdAvailable('text_2')).toBe(true);
   });
 
   it('isIdAvailable should return true when ID is returned (freed up)', () => {
-    expect(manager.isIdAvailable('text_1')).toBe(true);
-    manager.addID('text_1');
-    expect(manager.isIdAvailable('text_1')).toBe(false);
-    manager.removeId('text_1');
-    expect(manager.isIdAvailable('text_1')).toBe(true);
+    expect(idService.isIdAvailable('text_1')).toBe(true);
+    idService.addID('text_1');
+    expect(idService.isIdAvailable('text_1')).toBe(false);
+    idService.removeId('text_1');
+    expect(idService.isIdAvailable('text_1')).toBe(true);
   });
 });
-- 
GitLab