2
有一個輸入類型的文件元素。在多次角度文件上傳過程中,該值未被清除。因此,手動清除它使用普通的JavaScript DOM操縱。如何從業力測試中模擬dom元素
下面是代碼:
function removeFromQueue(item) {
vm.uploads.uploader.removeFromQueue(item);
// Clearing input file field for re-uploading
if(!vm.uploadFile) {
document.getElementById('upload-file-' + vm.type).value = null;
}
}
在這種情況下,不能夠嘲笑document.getElementById
,因此使用vm.uploadFile
未定義的變量從單元測試用例這是錯誤的控制它。如何在這裏模擬dom元素?