1- import { describe , expect , it , vi } from "vitest" ;
1+ import { describe , expect , it } from "vitest" ;
22import { render } from "vitest-browser-react" ;
33import type { DocumentJson } from "../../parser/document" ;
44import { TagCatalogProvider } from "../../tags/TagCatalogProvider" ;
@@ -14,7 +14,6 @@ describe("PersNamePart", () => {
1414 value : [ ] ,
1515 } ,
1616 "forename" ,
17- null ,
1817 ] ,
1918 [
2019 {
@@ -23,7 +22,6 @@ describe("PersNamePart", () => {
2322 value : [ ] ,
2423 } ,
2524 "honorific" ,
26- null ,
2725 ] ,
2826 [
2927 {
@@ -32,7 +30,6 @@ describe("PersNamePart", () => {
3230 value : [ ] ,
3331 } ,
3432 "degree" ,
35- null ,
3633 ] ,
3734 [
3835 {
@@ -41,7 +38,6 @@ describe("PersNamePart", () => {
4138 value : [ ] ,
4239 } ,
4340 null ,
44- "PersNamePart roleName missing or invalid @type:" ,
4541 ] ,
4642 [
4743 {
@@ -50,73 +46,55 @@ describe("PersNamePart", () => {
5046 value : [ ] ,
5147 } ,
5248 null ,
53- "PersNamePart roleName missing or invalid @type:" ,
5449 ] ,
5550 [
5651 {
5752 tag : "surname" ,
5853 value : [ ] ,
5954 } ,
6055 "surname" ,
61- null ,
6256 ] ,
6357 [
6458 {
6559 tag : "genName" ,
6660 value : [ ] ,
6761 } ,
6862 "genName" ,
69- null ,
7063 ] ,
7164 [
7265 {
7366 tag : "nameLink" ,
7467 value : [ ] ,
7568 } ,
7669 "nameLink" ,
77- null ,
7870 ] ,
7971 [
8072 {
8173 tag : "addName" ,
8274 value : [ ] ,
8375 } ,
8476 "addName" ,
85- null ,
8677 ] ,
8778 [
8879 {
8980 tag : "orgName" ,
9081 value : [ ] ,
9182 } ,
9283 "orgName" ,
93- null ,
9484 ] ,
9585 [
9686 {
9787 tag : "unknownTag" ,
9888 value : [ ] ,
9989 } ,
10090 null ,
101- "PersNamePart unknown tag:" ,
10291 ] ,
10392 ] ) ( "should return description type" , ( input : DocumentJson , expected :
10493 | string
105- | null , warning : string | null ) => {
106- const consoleWarnSpy = vi
107- . spyOn ( console , "warn" )
108- . mockImplementation ( ( ) => { } ) ;
94+ | null ) => {
10995 const descriptionKey = getDescriptionKey ( input ) ;
11096
11197 expect ( descriptionKey ) . toBe ( expected ) ;
112-
113- if ( warning ) {
114- expect ( consoleWarnSpy ) . toHaveBeenCalledWith ( warning , input ) ;
115- } else {
116- expect ( consoleWarnSpy ) . not . toHaveBeenCalled ( ) ;
117- }
118-
119- consoleWarnSpy . mockRestore ( ) ;
12098 } ) ;
12199 } ) ;
122100
@@ -146,9 +124,6 @@ describe("PersNamePart", () => {
146124 } ) ;
147125
148126 it ( "should render PersNamePart value without aria-description for unknown description type" , async ( ) => {
149- const consoleWarnSpy = vi
150- . spyOn ( console , "warn" )
151- . mockImplementation ( ( ) => { } ) ;
152127 const { getByText } = await render (
153128 < PersNamePart
154129 data = { {
@@ -169,24 +144,9 @@ describe("PersNamePart", () => {
169144 const spanElement = getByText ( "Unknown Role" ) ;
170145 expect ( spanElement ) . toBeInTheDocument ( ) ;
171146 expect ( spanElement ) . not . toHaveAttribute ( "aria-description" ) ;
172-
173- expect ( consoleWarnSpy ) . toHaveBeenCalledWith (
174- "PersNamePart roleName missing or invalid @type:" ,
175- {
176- tag : "roleName" ,
177- attributes : { "@type" : "unknown" } ,
178- value : [ { tag : "#text" , value : "Unknown Role" } ] ,
179- } ,
180- ) ;
181-
182- consoleWarnSpy . mockRestore ( ) ;
183147 } ) ;
184148
185- it ( "should render nothing and log a warning if data.value is not an array" , async ( ) => {
186- const consoleWarnSpy = vi
187- . spyOn ( console , "warn" )
188- . mockImplementation ( ( ) => { } ) ;
189-
149+ it ( "should render nothing if data.value is not an array" , async ( ) => {
190150 const { container } = await render (
191151 < PersNamePart
192152 data = { {
@@ -204,20 +164,9 @@ describe("PersNamePart", () => {
204164 ) ;
205165
206166 expect ( container ) . toBeEmptyDOMElement ( ) ;
207-
208- expect ( consoleWarnSpy ) . toHaveBeenCalledWith (
209- "PersName data.value is not an array:" ,
210- "Not an array" ,
211- ) ;
212-
213- consoleWarnSpy . mockRestore ( ) ;
214167 } ) ;
215168
216- it ( "should render nothing and log a warning if data.value is an empty array" , async ( ) => {
217- const consoleWarnSpy = vi
218- . spyOn ( console , "warn" )
219- . mockImplementation ( ( ) => { } ) ;
220-
169+ it ( "should render nothing if data.value is an empty array" , async ( ) => {
221170 const { container } = await render (
222171 < PersNamePart
223172 data = { {
@@ -235,15 +184,5 @@ describe("PersNamePart", () => {
235184 ) ;
236185
237186 expect ( container ) . toBeEmptyDOMElement ( ) ;
238-
239- expect ( consoleWarnSpy ) . toHaveBeenCalledWith (
240- "PersNamePart data.value is empty:" ,
241- {
242- tag : "forename" ,
243- value : [ ] ,
244- } ,
245- ) ;
246-
247- consoleWarnSpy . mockRestore ( ) ;
248187 } ) ;
249188} ) ;
0 commit comments