MCPcopy Index your code
hub / github.com/bugy/script-server / assertLine

Function assertLine

web-src/tests/unit/terminal_view_test.js:121–167  ·  view source on GitHub ↗
(lineElement, expectedNodes)

Source from the content-addressed store, hash-verified

119 }
120
121 function assertLine(lineElement, expectedNodes) {
122 expect(lineElement.tagName).toBe('DIV')
123
124 const actualNodes = [];
125 for (const childNode of lineElement.childNodes) {
126 const text = getText(childNode);
127
128 if (childNode.nodeType === 3) {
129 actualNodes.push(textNode(text));
130 continue;
131 }
132
133 if (childNode.tagName === 'A') {
134 actualNodes.push(anchorNode(text, []));
135 continue;
136 }
137
138 expect(childNode.tagName).toBe('SPAN')
139
140 const classes = getElementClasses(childNode);
141
142 if (childNode.childNodes.length === 1) {
143 if (childNode.childNodes[0].nodeType === 3) {
144 actualNodes.push(styledNode(text, classes));
145 continue;
146 }
147
148 expect(childNode.childNodes[0].tagName).toBe('A')
149 actualNodes.push(anchorNode(text, classes));
150 continue;
151 }
152
153 const grandChildrenNodes = [];
154 for (const grandchild of childNode.childNodes) {
155 if (grandchild.nodeType === 3) {
156 grandChildrenNodes.push(textNode(getTextNodeText(grandchild)));
157 continue;
158 }
159
160 expect(grandchild.tagName).toBe('A')
161 grandChildrenNodes.push(anchorNode(getText(grandchild)));
162 }
163 actualNodes.push(styledComplexNode(classes, grandChildrenNodes));
164 }
165
166 expect(expectedNodes).toEqual(actualNodes)
167 }
168
169 function assertImageLine(lineElement, expectedSrc) {
170 expect(lineElement.tagName).toBe('DIV')

Callers 1

Calls 8

textNodeFunction · 0.85
anchorNodeFunction · 0.85
getElementClassesFunction · 0.85
styledNodeFunction · 0.85
getTextNodeTextFunction · 0.85
styledComplexNodeFunction · 0.85
getTextFunction · 0.70
pushMethod · 0.45

Tested by

no test coverage detected