@@ -59,12 +59,12 @@ class UmbTestConditionAlwaysInvalid extends UmbControllerBase implements UmbExte
5959
6060describe ( 'UmbBaseExtensionController' , ( ) => {
6161 describe ( 'Manifest without conditions' , ( ) => {
62- // let hostElement: UmbControllerHostElement;
62+ let hostElement : UmbControllerHostElement ;
6363 let extensionRegistry : UmbExtensionRegistry < ManifestWithDynamicConditions > ;
6464 let manifest : ManifestWithDynamicConditions ;
6565
6666 beforeEach ( async ( ) => {
67- // hostElement = await fixture(html`<umb-test-controller-host></umb-test-controller-host>`);
67+ hostElement = await fixture ( html `< umb-test-controller-host > </ umb-test-controller-host > ` ) ;
6868 extensionRegistry = new UmbExtensionRegistry ( ) ;
6969 manifest = {
7070 type : 'section' ,
@@ -74,7 +74,7 @@ describe('UmbBaseExtensionController', () => {
7474
7575 extensionRegistry . register ( manifest ) ;
7676 } ) ;
77- /*
77+
7878 it ( 'permits when there is no conditions' , ( done ) => {
7979 const extensionController = new UmbTestExtensionController (
8080 hostElement ,
@@ -92,16 +92,15 @@ describe('UmbBaseExtensionController', () => {
9292 } ,
9393 ) ;
9494 } ) ;
95- */
9695 } ) ;
9796
9897 describe ( 'Manifest with empty conditions' , ( ) => {
99- // let hostElement: UmbControllerHostElement;
98+ let hostElement : UmbControllerHostElement ;
10099 let extensionRegistry : UmbExtensionRegistry < ManifestWithDynamicConditions > ;
101100 let manifest : ManifestWithDynamicConditions ;
102101
103102 beforeEach ( async ( ) => {
104- // hostElement = await fixture(html`<umb-test-controller-host></umb-test-controller-host>`);
103+ hostElement = await fixture ( html `< umb-test-controller-host > </ umb-test-controller-host > ` ) ;
105104 extensionRegistry = new UmbExtensionRegistry ( ) ;
106105 manifest = {
107106 type : 'section' ,
@@ -113,7 +112,6 @@ describe('UmbBaseExtensionController', () => {
113112 extensionRegistry . register ( manifest ) ;
114113 } ) ;
115114
116- /*
117115 it ( 'permits when there is empty conditions' , ( done ) => {
118116 const extensionController = new UmbTestExtensionController (
119117 hostElement ,
@@ -124,15 +122,14 @@ describe('UmbBaseExtensionController', () => {
124122 if ( extensionController . permitted ) {
125123 expect ( extensionController ?. manifest ?. alias ) . to . eq ( 'Umb.Test.Section.1' ) ;
126124
127- // Also verifying that the promise gets resolved.
125+ // Also verifying that the promise gets resolved. [NL]
128126 extensionController . asPromise ( ) . then ( ( ) => {
129127 done ( ) ;
130128 } ) ;
131129 }
132130 } ,
133131 ) ;
134132 } ) ;
135- */
136133 } ) ;
137134
138135 describe ( 'Manifest with valid conditions' , ( ) => {
@@ -225,14 +222,14 @@ describe('UmbBaseExtensionController', () => {
225222 if ( isPermitted ) {
226223 count ++ ;
227224 if ( count === 1 ) {
228- // First time render, there is no conditions.
225+ // First time render, there is no conditions. [NL]
229226 expect ( extensionController . manifest ?. weight ) . to . be . equal ( 2 ) ;
230227 expect ( extensionController . manifest ?. conditions ?. length ) . to . be . equal ( 1 ) ;
231228 } else if ( count === 2 ) {
232- // Second time render, there is conditions and weight is 22.
229+ // Second time render, there is conditions and weight is 22. [NL]
233230 expect ( extensionController . manifest ?. weight ) . to . be . equal ( 22 ) ;
234231 expect ( extensionController . manifest ?. conditions ?. length ) . to . be . equal ( 1 ) ;
235- // Check that the promise has been resolved for the first render to ensure timing is right.
232+ // Check that the promise has been resolved for the first render to ensure timing is right. [NL]
236233 expect ( initialPromiseResolved ) . to . be . true ;
237234 done ( ) ;
238235 extensionController . destroy ( ) ;
@@ -270,14 +267,14 @@ describe('UmbBaseExtensionController', () => {
270267 if ( isPermitted ) {
271268 count ++ ;
272269 if ( count === 1 ) {
273- // First time render, there is no conditions.
270+ // First time render, there is no conditions. [NL]
274271 expect ( extensionController . manifest ?. weight ) . to . be . equal ( 3 ) ;
275272 expect ( extensionController . manifest ?. conditions ?. length ) . to . be . equal ( 0 ) ;
276273 } else if ( count === 2 ) {
277- // Second time render, there is conditions and weight is 33.
274+ // Second time render, there is conditions and weight is 33. [NL]
278275 expect ( extensionController . manifest ?. weight ) . to . be . equal ( 33 ) ;
279276 expect ( extensionController . manifest ?. conditions ?. length ) . to . be . equal ( 0 ) ;
280- // Check that the promise has been resolved for the first render to ensure timing is right.
277+ // Check that the promise has been resolved for the first render to ensure timing is right. [NL]
281278 expect ( initialPromiseResolved ) . to . be . true ;
282279 done ( ) ;
283280 extensionController . destroy ( ) ;
@@ -315,14 +312,14 @@ describe('UmbBaseExtensionController', () => {
315312 if ( isPermitted ) {
316313 count ++ ;
317314 if ( count === 1 ) {
318- // First time render, there is no conditions.
315+ // First time render, there is no conditions. [NL]
319316 expect ( extensionController . manifest ?. weight ) . to . be . equal ( 4 ) ;
320317 expect ( extensionController . manifest ?. conditions ?. length ) . to . be . equal ( 0 ) ;
321318 } else if ( count === 2 ) {
322- // Second time render, there is conditions and weight is 33.
319+ // Second time render, there is conditions and weight is updated. [NL]
323320 expect ( extensionController . manifest ?. weight ) . to . be . equal ( 44 ) ;
324321 expect ( extensionController . manifest ?. conditions ?. length ) . to . be . equal ( 1 ) ;
325- // Check that the promise has been resolved for the first render to ensure timing is right.
322+ // Check that the promise has been resolved for the first render to ensure timing is right. [NL]
326323 expect ( initialPromiseResolved ) . to . be . true ;
327324 done ( ) ;
328325 extensionController . destroy ( ) ;
@@ -370,14 +367,14 @@ describe('UmbBaseExtensionController', () => {
370367 if ( isPermitted ) {
371368 count ++ ;
372369 if ( count === 1 ) {
373- // First time render, there is no conditions.
370+ // First time render, there is no conditions. [NL]
374371 expect ( extensionController . manifest ?. weight ) . to . be . undefined ;
375372 expect ( extensionController . manifest ?. conditions ?. length ) . to . be . equal ( 0 ) ;
376373 } else if ( count === 2 ) {
377- // Second time render, there is a matching kind and then weight is 123.
374+ // Second time render, there is a matching kind and then weight is 123. [NL]
378375 expect ( extensionController . manifest ?. weight ) . to . be . equal ( 123 ) ;
379376 expect ( extensionController . manifest ?. conditions ?. length ) . to . be . equal ( 0 ) ;
380- // Check that the promise has been resolved for the first render to ensure timing is right.
377+ // Check that the promise has been resolved for the first render to ensure timing is right. [NL]
381378 expect ( initialPromiseResolved ) . to . be . true ;
382379 done ( ) ;
383380 extensionController . destroy ( ) ;
@@ -433,7 +430,7 @@ describe('UmbBaseExtensionController', () => {
433430 'Umb.Test.Section.1' ,
434431 ( ) => {
435432 // This should not be called.
436- expect ( true ) . to . be . false ;
433+ expect . fail ( 'Callback should not be called when never permitted' ) ;
437434 } ,
438435 ) ;
439436 Promise . resolve ( ) . then ( ( ) => {
@@ -451,7 +448,7 @@ describe('UmbBaseExtensionController', () => {
451448 'Umb.Test.Section.1' ,
452449 ( ) => {
453450 // This should not be called.
454- expect ( true ) . to . be . false ;
451+ expect . fail ( 'Callback should not be called when never permitted' ) ;
455452 } ,
456453 ) ;
457454
@@ -531,7 +528,7 @@ describe('UmbBaseExtensionController', () => {
531528 'Umb.Test.Section.1' ,
532529 async ( ) => {
533530 count ++ ;
534- // We want the controller callback to first fire when conditions are initialized.
531+ // We want the controller callback to first fire when conditions are initialized. [NL]
535532 expect ( extensionController . manifest ?. conditions ?. length ) . to . be . equal ( 1 ) ;
536533 expect ( extensionController ?. manifest ?. alias ) . to . eq ( 'Umb.Test.Section.1' ) ;
537534 if ( count === 1 ) {
@@ -596,29 +593,30 @@ describe('UmbBaseExtensionController', () => {
596593 'Umb.Test.Section.1' ,
597594 async ( isPermitted ) => {
598595 count ++ ;
599- // We want the controller callback to first fire when conditions are initialized.
596+ // We want the controller callback to first fire when conditions are initialized. [NL]
600597 expect ( extensionController . manifest ?. conditions ?. length ) . to . be . equal ( 2 ) ;
601598 expect ( extensionController ?. manifest ?. alias ) . to . eq ( 'Umb.Test.Section.1' ) ;
602599 if ( count === 1 ) {
603600 expect ( isPermitted ) . to . be . true ;
604601 expect ( extensionController ?. permitted ) . to . be . true ;
605- // Hack to double check that its two conditions that make up the state:
602+ // Hack to double check that its two conditions that make up the state: [NL]
606603 expect (
607604 extensionController . getUmbControllers ( ( controller ) => ( controller as any ) . permitted ) . length ,
608605 ) . to . equal ( 2 ) ;
609606 } else if ( count === 2 ) {
610607 expect ( isPermitted ) . to . be . false ;
611608 expect ( extensionController ?. permitted ) . to . be . false ;
612- // Hack to double check that its two conditions that make up the state, in this case its one, cause we already got the callback when one of the conditions changed. meaning in this split second one is still good:
609+ // Hack to double check that its two conditions that make up the state, in this case its one, cause we already got the callback when one of the conditions changed. meaning in this split second one is still good: [NL]
613610 expect (
614611 extensionController . getUmbControllers ( ( controller ) => ( controller as any ) . permitted ) . length ,
615612 ) . to . equal ( 1 ) ;
616613
617614 // Then we are done:
618615 extensionController . destroy ( ) ; // End this test.
619- setTimeout ( ( ) => done ( ) , 60 ) ; // Lets wait another round of the conditions approve/disapprove, just to see if the destroy stopped the conditions. (60ms, as that should be enough to test that another round does not happen.)
616+ setTimeout ( ( ) => done ( ) , 60 ) ; // Lets wait another round of the conditions approve/disapprove, just to see if the destroy stopped the conditions. (60ms, as that should be enough to test that another round does not happen.) [NL]
620617 } else if ( count === 5 ) {
621- expect ( false ) . to . be . true ; // This should not be called.
618+ // This should not be called.
619+ expect . fail ( 'Callback should not be called when never permitted' ) ;
622620 }
623621 } ,
624622 ) ;
0 commit comments