假设我有一个功能
function f_createScriptElement(f_url) {
var script = d[CreateElement](Script);
script.type = "text/javascript";
script[Src] = f_url;
script.async = true;
try {
var container = ((m_videoPlayerTagId) ? d[GetElementById](m_videoPlayerTagId) : f_getAdContainerElem());
if (container) {
container.addEventListener("loadedmetadata", function(e) {
var c_width = this.videoWidth,
c_height = this.videoHeight,
v_width = this[WIDTH],
v_height = this[HEIGHT];
m_playerProperties[NS_AD_CD] = container.duration;
m_playerProperties[NS_AD_SZ] = c_width + "x" + c_height;
m_playerProperties[NS_AD_PS] = v_width + "x" + v_height;
m_playerProperties[NS_AD_VS] = ((container.volume === 0) ? false : true);
}, false);
container.parentNode.insertBefore(script, container.nextSibling);
} else {
return;
}
} catch (err) {}
}
如果你能告诉你将编写的适当的测试用例(正面和负面)在 QUnit 中对这个函数有完整的代码覆盖,那就太好了,因为它不返回字符串或数字。