From 576e3e21d1e89029234f8ef5dc0c6ea3567e5fb1 Mon Sep 17 00:00:00 2001
From: rhenck <richard.henck@iqb.hu-berlin.de>
Date: Mon, 30 Sep 2024 12:16:27 +0200
Subject: [PATCH] [editor] Fix IDService tests to work with changed mehtod
 visibility

All created IDs are now always registered as well.
---
 projects/common/services/sanitization.service.ts |  2 +-
 .../editor/src/app/services/id.service.spec.ts   | 16 ++++++++--------
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/projects/common/services/sanitization.service.ts b/projects/common/services/sanitization.service.ts
index bb7e2b5e2..153862d32 100644
--- a/projects/common/services/sanitization.service.ts
+++ b/projects/common/services/sanitization.service.ts
@@ -88,7 +88,7 @@ export class SanitizationService {
     if (!idManager.isIdAvailable(element.id)) {
       console.warn(`Id already in: ${element.id}! Generating a new one...`);
       this.repairLog.push(element.id);
-      element.id = idManager.getNewID((element as UIElement).type || 'value');
+      element.id = idManager.getAndRegisterNewID((element as UIElement).type || 'value');
     }
     idManager.addID(element.id);
 
diff --git a/projects/editor/src/app/services/id.service.spec.ts b/projects/editor/src/app/services/id.service.spec.ts
index 348c2ad58..79aabb167 100644
--- a/projects/editor/src/app/services/id.service.spec.ts
+++ b/projects/editor/src/app/services/id.service.spec.ts
@@ -16,22 +16,22 @@ describe('IDService', () => {
     idService.reset();
   });
 
-  it('getNewID should fail on empty string param', () => {
-    expect(() => { idService.getNewID(''); }).toThrow(Error('ID-Service: No type given!'));
+  it('getAndRegisterNewID should fail on empty string param', () => {
+    expect(() => { idService.getAndRegisterNewID(''); }).toThrow(Error('ID-Service: No type given!'));
   });
 
-  it('getNewID should return first ID', () => {
-    expect(idService.getNewID('text')).toBe('text_1');
+  it('getAndRegisterNewID should return first ID', () => {
+    expect(idService.getAndRegisterNewID('text')).toBe('text_1');
   });
 
-  it('getNewID should return different IDs - counting up', () => {
-    idService.getNewID('text');
-    expect(idService.getNewID('text')).toBe('text_2');
+  it('getAndRegisterNewID should return different IDs - counting up', () => {
+    idService.getAndRegisterNewID('text');
+    expect(idService.getAndRegisterNewID('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');
+    expect(idService.getAndRegisterNewID('text')).toBe('text_2');
   });
 
   it('isIdAvailable should return false when id is already taken', () => {
-- 
GitLab