File tree Expand file tree Collapse file tree
gateway/sds_gateway/static/js/core/__tests__ Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55
66import { DOMUtils } from "../DOMUtils.js" ;
77
8+ /** Approximate Element.textContent from innerHTML for mock nodes (strip tags, decode entities). */
9+ function mockTextContentFromHtml ( html ) {
10+ if ( html == null || html === "" ) return "" ;
11+ const noTags = String ( html ) . replace ( / < [ ^ > ] * > / g, "" ) ;
12+ return noTags
13+ . replace ( / & l t ; / g, "<" )
14+ . replace ( / & g t ; / g, ">" )
15+ . replace ( / & a m p ; / g, "&" ) ;
16+ }
17+
818describe ( "DOMUtils" , ( ) => {
919 let domUtils ;
1020 let mockAPIClient ;
@@ -27,6 +37,12 @@ describe("DOMUtils", () => {
2737 querySelector : jest . fn ( ) ,
2838 querySelectorAll : jest . fn ( ( ) => [ ] ) ,
2939 } ;
40+ Object . defineProperty ( mockContainer , "textContent" , {
41+ get ( ) {
42+ return mockTextContentFromHtml ( this . innerHTML ) ;
43+ } ,
44+ configurable : true ,
45+ } ) ;
3046
3147 mockToastContainer = {
3248 id : "toast-container" ,
You can’t perform that action at this time.
0 commit comments