From e75d483ca2350a68a084f4d7ff899a5f5e1f4474 Mon Sep 17 00:00:00 2001
From: jojohoch <joachim.hoch@iqb.hu-berlin.de>
Date: Mon, 14 Oct 2024 11:04:03 +0200
Subject: [PATCH] Fix unittest for mapping service

---
 ...ent-model-element-code-mapping.service.spec.ts | 15 ++++++++-------
 test-data/element-models/text_130.json            |  1 +
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/projects/player/src/app/services/element-model-element-code-mapping.service.spec.ts b/projects/player/src/app/services/element-model-element-code-mapping.service.spec.ts
index 979acd4f0..781dabd8c 100644
--- a/projects/player/src/app/services/element-model-element-code-mapping.service.spec.ts
+++ b/projects/player/src/app/services/element-model-element-code-mapping.service.spec.ts
@@ -376,23 +376,24 @@ describe('ElementModelElementCodeMappingService', () => {
       .toEqual([]);
   });
 
-  it('should not modify the elementCode and return the code', () => {
+  it('should map an elementCode value to text elementModel value (text)', () => {
     const elementModel: TextElement = JSON.parse(JSON.stringify(text_130));
-    elementModel.markingMode = 'selection';
+    const expectedValue =
+      'Lorem <aspect-marked style="background-color: rgb(249, 248, 113);">ipsum</aspect-marked> dolor sit amet';
     expect(service.mapToElementModelValue(['6-11-#f9f871'], elementModel))
-      .toEqual(['6-11-#f9f871']);
+      .toEqual(expectedValue);
   });
 
-  it('should not modify the elementCode and return the empty array', () => {
+  it('should not map but return the text elementModel value (text)', () => {
     const elementModel: TextElement = JSON.parse(JSON.stringify(text_130));
     expect(service.mapToElementModelValue([], elementModel))
-      .toEqual([]);
+      .toEqual(elementModel.text);
   });
 
-  it('should modify the undefined elementCode and return an empty array', () => {
+  it('should not map but return the text elementModel value (text)', () => {
     const elementModel: TextElement = JSON.parse(JSON.stringify(text_130));
     expect(service.mapToElementModelValue(undefined, elementModel))
-      .toEqual([]);
+      .toEqual(elementModel.text);
   });
 
   it('should map an elementCode value to audio elementModel value', () => {
diff --git a/test-data/element-models/text_130.json b/test-data/element-models/text_130.json
index ba5d57183..9d685177e 100644
--- a/test-data/element-models/text_130.json
+++ b/test-data/element-models/text_130.json
@@ -4,6 +4,7 @@
   "width": 180,
   "height": 98,
   "text": "Lorem ipsum dolor sit amet",
+  "markingMode": "selection",
   "highlightableOrange": false,
   "highlightableTurquoise": false,
   "highlightableYellow": true,
-- 
GitLab