function download(filename, text) {
  const element = document.createElement('a');
  element.setAttribute('href', `data:text/plain;charset=utf-8,${encodeURIComponent(text)}`);
  element.setAttribute('download', filename);
  element.style.display = 'none';
  document.body.appendChild(element);
  element.click();
  document.body.removeChild(element);
}

module.exports = { download };

@@ -25,16 +25,30 @@
 me, text
+, click = true
 ) %7B%0A  co
@@ -301,16 +301,33 @@
 ement);%0A
+  if (click) %7B%0A  
   elemen
@@ -337,16 +337,20 @@
 lick();%0A
+  %7D%0A
   docume
@@ -379,16 +379,34 @@
 ement);%0A
+  return document%0A
 %7D%0A%0Amodul

Return documents to make it easier to test