We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bac761c commit 4dd579fCopy full SHA for 4dd579f
test/unit/tw_external.js
@@ -17,7 +17,22 @@ test('fetch', t => {
17
});
18
19
20
-// Node.js does not support FileReader (yet?) so not really possible to properly test dataURL
+test('dataURL', t => {
21
+ global.FileReader = class {
22
+ readAsDataURL (blob) {
23
+ blob.arrayBuffer().then(arrayBuffer => {
24
+ const base64 = Buffer.from(arrayBuffer).toString('base64');
25
+ this.result = `data:${blob.type};base64,${base64}`;
26
+ this.onload();
27
+ });
28
+ }
29
+ };
30
+
31
+ external.dataURL('data:text/plain;,doesthiswork').then(dataURL => {
32
+ t.equal(dataURL, `data:text/plain;base64,${btoa('doesthiswork')}`);
33
+ t.end();
34
35
+});
36
37
test('blob', t => {
38
external.blob('data:text/plain;,test').then(blob => {
0 commit comments