11import { Component , ViewChild , input , type TemplateRef } from '@angular/core'
22import { TestBed , type ComponentFixture } from '@angular/core/testing'
33import { createColumnHelper } from '@tanstack/table-core'
4- import { skip } from 'node:test'
54import { describe , expect , test } from 'vitest'
65import {
76 FlexRenderComponent ,
@@ -24,6 +23,20 @@ describe('FlexRenderDirective', () => {
2423 test ( 'should render primitives' , async ( ) => {
2524 const fixture = TestBed . createComponent ( TestRenderComponent )
2625
26+ // Null
27+ setFixtureSignalInputs ( fixture , {
28+ content : ( ) => null ,
29+ context : { } ,
30+ } )
31+ expect ( ( fixture . nativeElement as HTMLElement ) . matches ( ':empty' ) ) . toBe ( true )
32+
33+ // Undefined
34+ setFixtureSignalInputs ( fixture , {
35+ content : ( ) => undefined ,
36+ context : { } ,
37+ } )
38+ expect ( ( fixture . nativeElement as HTMLElement ) . matches ( ':empty' ) ) . toBe ( true )
39+
2740 // String
2841 setFixtureSignalInputs ( fixture , {
2942 content : 'My value' ,
@@ -45,19 +58,12 @@ describe('FlexRenderDirective', () => {
4558 } )
4659 expectPrimitiveValueIs ( fixture , 'My value 2' )
4760
48- // Null
61+ // Set again to null to be sure content has been destroyed
4962 setFixtureSignalInputs ( fixture , {
5063 content : ( ) => null ,
5164 context : { } ,
5265 } )
53- expectPrimitiveValueIs ( fixture , '' )
54-
55- // Undefined
56- setFixtureSignalInputs ( fixture , {
57- content : ( ) => undefined ,
58- context : { } ,
59- } )
60- expectPrimitiveValueIs ( fixture , '' )
66+ expect ( ( fixture . nativeElement as HTMLElement ) . matches ( ':empty' ) ) . toBe ( true )
6167 } )
6268
6369 test ( 'should render TemplateRef' , ( ) => {
@@ -118,7 +124,7 @@ describe('FlexRenderDirective', () => {
118124
119125 // Skip for now, test framework (using ComponentRef.setInput) cannot recognize signal inputs
120126 // as component inputs
121- skip ( 'should render custom components' , ( ) => {
127+ test . skip ( 'should render custom components' , ( ) => {
122128 @Component ( {
123129 template : `{{ row().property }}` ,
124130 standalone : true ,
@@ -172,6 +178,7 @@ function expectPrimitiveValueIs(
172178 fixture : ComponentFixture < unknown > ,
173179 value : unknown
174180) {
181+ expect ( fixture . nativeElement . matches ( ':empty' ) ) . toBe ( false )
175182 const span = fixture . nativeElement . querySelector ( 'span' )
176183 expect ( span ) . toBeDefined ( )
177184 expect ( span . innerHTML ) . toEqual ( value )
0 commit comments