Tim
05/01/2024, 9:49 PMvar testValue = '{abc:"def"}';
var actualValue = myComponent.getFormattedText(testValue);
expect(actualValue).toInclude(EncodeForXML(testValue));
And that's "failing" because
The needle [{abc:"def"}] was not found in [<?xml version="1.0" encoding="UTF-8"?><record><datum key="id">{abc:"def"}</datum></record>I think it's worth noting that getFormattedText also runs testValue through EncodeForXML under the hood. So it's especially a mystery to me why it comes out nice on one side, but not on the other. Why is EncodeForXML feeling a need to encode the braces and quotes in one string, but not the other, causing them to not match?
Adam Cameron
EncodeForXML
on the needle. You're not encoding {abc:"def"}
in the XML, and comparing it to the encoded version.
I mean... the test failure is even showing you... exactly... erm... that...
{abc:"def"}
clearly isn't the same as {abc:"def"}
, right?Tim
05/02/2024, 3:58 PM{abc:"def"}
in the XML though... So I couldn't understand why they were encoding differently.
If anything, I was expecting
<?xml version="1.0" encoding="UTF-8"?><record><datum key="id">{abc:"def"}</datum></record>
But I figured it out. The raw XML I'm returning is actually this:
<dataset type="null"><record><datum key="id">{abc:"def"}</datum></record></dataset>
But then I was parsing out the record tags to get a count of rows returned via XMLSearch(XMLParse())
(which I had forgotten about) and so the actualValue
in my test was really an XML object, which it seems TestBox was running ToString
on, and when CF output the string, it encodes things differently than EncodeForXML
does.Tim
05/02/2024, 4:01 PM