@@ -2,8 +2,10 @@ import { ValueCellComponent } from './value-cell.component';
22import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core' ;
33import { ComponentFixture , TestBed } from '@angular/core/testing' ;
44import { LuigiClient } from '@luigi-project/client/luigi-element' ;
5- import { FieldDefinition , Resource } from '@platform-mesh/portal-ui-lib/models/models' ;
6-
5+ import {
6+ FieldDefinition ,
7+ Resource ,
8+ } from '@platform-mesh/portal-ui-lib/models/models' ;
79
810describe ( 'ValueCellComponent' , ( ) => {
911 let component : ValueCellComponent ;
@@ -164,7 +166,9 @@ describe('ValueCellComponent', () => {
164166 describe ( 'labelDisplay functionality' , ( ) => {
165167 it ( 'should render label-value component when labelDisplay is an object' , ( ) => {
166168 const labelDisplay = { backgroundColor : '#ffffff' , color : '#000000' } ;
167- const { fixture } = makeComponent ( 'test-value' , { labelDisplay } ) ;
169+ const { fixture } = makeComponent ( 'test-value' , {
170+ uiSettings : { labelDisplay } ,
171+ } ) ;
168172 const compiled = fixture . nativeElement ;
169173
170174 expect ( compiled . querySelector ( 'wc-label-value' ) ) . toBeTruthy ( ) ;
@@ -173,7 +177,9 @@ describe('ValueCellComponent', () => {
173177 } ) ;
174178
175179 it ( 'should render label-value component when labelDisplay is true' , ( ) => {
176- const { fixture } = makeComponent ( 'test-value' , { labelDisplay : true } ) ;
180+ const { fixture } = makeComponent ( 'test-value' , {
181+ uiSettings : { labelDisplay : true } ,
182+ } ) ;
177183 const compiled = fixture . nativeElement ;
178184
179185 expect ( compiled . querySelector ( 'wc-label-value' ) ) . toBeTruthy ( ) ;
@@ -182,7 +188,9 @@ describe('ValueCellComponent', () => {
182188 } ) ;
183189
184190 it ( 'should not render label-value component when labelDisplay is false' , ( ) => {
185- const { fixture } = makeComponent ( 'test-value' , { labelDisplay : false } ) ;
191+ const { fixture } = makeComponent ( 'test-value' , {
192+ uiSettings : { labelDisplay : false } ,
193+ } ) ;
186194 const compiled = fixture . nativeElement ;
187195
188196 expect ( compiled . querySelector ( 'wc-label-value' ) ) . toBeFalsy ( ) ;
@@ -192,7 +200,7 @@ describe('ValueCellComponent', () => {
192200
193201 it ( 'should not render label-value component when labelDisplay is undefined' , ( ) => {
194202 const { fixture } = makeComponent ( 'test-value' , {
195- labelDisplay : undefined ,
203+ uiSettings : { labelDisplay : undefined } ,
196204 } ) ;
197205 const compiled = fixture . nativeElement ;
198206
@@ -203,7 +211,7 @@ describe('ValueCellComponent', () => {
203211
204212 it ( 'should not render label-value component when labelDisplay is null' , ( ) => {
205213 const { fixture } = makeComponent ( 'test-value' , {
206- labelDisplay : null as any ,
214+ uiSettings : { labelDisplay : null as any } ,
207215 } ) ;
208216 const compiled = fixture . nativeElement ;
209217
@@ -214,7 +222,7 @@ describe('ValueCellComponent', () => {
214222
215223 it ( 'should render label-value component when labelDisplay is a string' , ( ) => {
216224 const { fixture } = makeComponent ( 'test-value' , {
217- labelDisplay : 'some-string' as any ,
225+ uiSettings : { labelDisplay : 'some-string' as any } ,
218226 } ) ;
219227 const compiled = fixture . nativeElement ;
220228
@@ -225,7 +233,7 @@ describe('ValueCellComponent', () => {
225233
226234 it ( 'should render label-value component when labelDisplay is a number' , ( ) => {
227235 const { fixture } = makeComponent ( 'test-value' , {
228- labelDisplay : 42 as any ,
236+ uiSettings : { labelDisplay : 42 as any } ,
229237 } ) ;
230238 const compiled = fixture . nativeElement ;
231239
@@ -235,39 +243,41 @@ describe('ValueCellComponent', () => {
235243 } ) ;
236244 } ) ;
237245
238- describe ( 'displayAsSecret functionality' , ( ) => {
239- it ( 'should render secret-value component when displayAsSecret is true ' , ( ) => {
246+ describe ( 'displayAs secret functionality' , ( ) => {
247+ it ( 'should render secret-value component when displayAs is secret ' , ( ) => {
240248 const { fixture } = makeComponent ( 'secret-password' , {
241- displayAsSecret : true ,
249+ uiSettings : { displayAs : 'secret' } ,
242250 } ) ;
243251 const compiled = fixture . nativeElement ;
244252
245253 expect ( compiled . querySelector ( 'wc-secret-value' ) ) . toBeTruthy ( ) ;
246- expect ( component . displayAsSecret ( ) ) . toBe ( true ) ;
254+ expect ( component . displayAs ( ) ) . toBe ( 'secret' ) ;
247255 } ) ;
248256
249- it ( 'should not render secret-value component when displayAsSecret is false ' , ( ) => {
257+ it ( 'should not render secret-value component when displayAs is not secret ' , ( ) => {
250258 const { fixture } = makeComponent ( 'plain-text' , {
251- displayAsSecret : false ,
259+ uiSettings : { displayAs : 'plainText' } ,
252260 } ) ;
253261 const compiled = fixture . nativeElement ;
254262
255263 expect ( compiled . querySelector ( 'wc-secret-value' ) ) . toBeFalsy ( ) ;
256- expect ( component . displayAsSecret ( ) ) . toBe ( false ) ;
264+ expect ( component . displayAs ( ) ) . toBe ( 'plainText' ) ;
257265 } ) ;
258266
259- it ( 'should not render secret-value component when displayAsSecret is undefined' , ( ) => {
267+ it ( 'should not render secret-value component when displayAs is undefined' , ( ) => {
260268 const { fixture } = makeComponent ( 'plain-text' ) ;
261269 const compiled = fixture . nativeElement ;
262270
263271 expect ( compiled . querySelector ( 'wc-secret-value' ) ) . toBeFalsy ( ) ;
264- expect ( component . displayAsSecret ( ) ) . toBeUndefined ( ) ;
272+ expect ( component . displayAs ( ) ) . toBeUndefined ( ) ;
265273 } ) ;
266274 } ) ;
267275
268276 describe ( 'withCopyButton functionality' , ( ) => {
269277 it ( 'should render copy button when withCopyButton is true' , ( ) => {
270- const { fixture } = makeComponent ( 'test-value' , { withCopyButton : true } ) ;
278+ const { fixture } = makeComponent ( 'test-value' , {
279+ uiSettings : { withCopyButton : true } ,
280+ } ) ;
271281 const compiled = fixture . nativeElement ;
272282
273283 expect ( compiled . querySelector ( 'ui5-icon[name="copy"]' ) ) . toBeTruthy ( ) ;
@@ -276,7 +286,7 @@ describe('ValueCellComponent', () => {
276286
277287 it ( 'should not render copy button when withCopyButton is false' , ( ) => {
278288 const { fixture } = makeComponent ( 'test-value' , {
279- withCopyButton : false ,
289+ uiSettings : { withCopyButton : false } ,
280290 } ) ;
281291 const compiled = fixture . nativeElement ;
282292
@@ -300,7 +310,7 @@ describe('ValueCellComponent', () => {
300310 const customLuigiClient = createMockLuigiClient ( showAlertSpy ) ;
301311 const { fixture } = makeComponent (
302312 'test-value' ,
303- { withCopyButton : true } ,
313+ { uiSettings : { withCopyButton : true } } ,
304314 customLuigiClient ,
305315 ) ;
306316
@@ -320,7 +330,9 @@ describe('ValueCellComponent', () => {
320330 } ) ;
321331
322332 it ( 'should stop event propagation when copy button is clicked' , ( ) => {
323- const { fixture } = makeComponent ( 'test-value' , { withCopyButton : true } ) ;
333+ const { fixture } = makeComponent ( 'test-value' , {
334+ uiSettings : { withCopyButton : true } ,
335+ } ) ;
324336 const compiled = fixture . nativeElement ;
325337 const copyButton = compiled . querySelector ( 'ui5-icon[name="copy"]' ) ;
326338
@@ -334,10 +346,10 @@ describe('ValueCellComponent', () => {
334346 } ) ;
335347 } ) ;
336348
337- describe ( 'displayAsPlainText functionality' , ( ) => {
338- it ( 'should render plain text when displayAsPlainText is true ' , ( ) => {
349+ describe ( 'displayAs plainText functionality' , ( ) => {
350+ it ( 'should render plain text when displayAs is plainText ' , ( ) => {
339351 const { fixture } = makeComponent ( 'test-value' , {
340- displayAsPlainText : true ,
352+ uiSettings : { displayAs : 'plainText' } ,
341353 } ) ;
342354 const compiled = fixture . nativeElement ;
343355
@@ -348,9 +360,9 @@ describe('ValueCellComponent', () => {
348360 expect ( compiled . textContent . trim ( ) ) . toContain ( 'test-value' ) ;
349361 } ) ;
350362
351- it ( 'should not render plain text when displayAsPlainText is false ' , ( ) => {
363+ it ( 'should not render plain text when displayAs is not plainText ' , ( ) => {
352364 const { fixture } = makeComponent ( 'https://example.com' , {
353- displayAsPlainText : false ,
365+ uiSettings : { } ,
354366 } ) ;
355367 const compiled = fixture . nativeElement ;
356368
@@ -650,7 +662,7 @@ describe('ValueCellComponent', () => {
650662
651663 it ( 'should prioritize boolean over label when both are valid' , ( ) => {
652664 const { fixture } = makeComponent ( 'true' , {
653- labelDisplay : { backgroundColor : '#ffffff' } ,
665+ uiSettings : { labelDisplay : { backgroundColor : '#ffffff' } } ,
654666 } ) ;
655667 const compiled = fixture . nativeElement ;
656668
@@ -661,7 +673,7 @@ describe('ValueCellComponent', () => {
661673
662674 it ( 'should prioritize URL over label when both are valid' , ( ) => {
663675 const { fixture } = makeComponent ( 'https://example.com' , {
664- labelDisplay : { backgroundColor : '#ffffff' } ,
676+ uiSettings : { labelDisplay : { backgroundColor : '#ffffff' } } ,
665677 } ) ;
666678 const compiled = fixture . nativeElement ;
667679
@@ -672,7 +684,7 @@ describe('ValueCellComponent', () => {
672684
673685 it ( 'should render label when boolean and URL are not valid but labelDisplay is provided' , ( ) => {
674686 const { fixture } = makeComponent ( 'some-text' , {
675- labelDisplay : { backgroundColor : '#ffffff' } ,
687+ uiSettings : { labelDisplay : { backgroundColor : '#ffffff' } } ,
676688 } ) ;
677689 const compiled = fixture . nativeElement ;
678690
@@ -682,7 +694,9 @@ describe('ValueCellComponent', () => {
682694 } ) ;
683695
684696 it ( 'should render plain text when no special rendering is needed' , ( ) => {
685- const { fixture } = makeComponent ( 'some-text' , { labelDisplay : false } ) ;
697+ const { fixture } = makeComponent ( 'some-text' , {
698+ uiSettings : { labelDisplay : false } ,
699+ } ) ;
686700 const compiled = fixture . nativeElement ;
687701
688702 expect ( compiled . querySelector ( 'wc-boolean-value' ) ) . toBeFalsy ( ) ;
@@ -691,4 +705,4 @@ describe('ValueCellComponent', () => {
691705 expect ( compiled . textContent . trim ( ) ) . toBe ( 'some-text' ) ;
692706 } ) ;
693707 } ) ;
694- } ) ;
708+ } ) ;
0 commit comments