-
Notifications
You must be signed in to change notification settings - Fork 1
/
setupFile.ts
56 lines (49 loc) · 1.4 KB
/
setupFile.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import { JSDOM } from 'jsdom'
import * as Papa from 'papaparse'
const globalAny: any = global
const documentHTML = '<!DOCTYPE html><html><body><div id="root"></div></body></html>'
globalAny.document = new JSDOM(documentHTML).window.document
globalAny.navigator = {
platform: 'Mac'
}
globalAny.File = class MockFile {
name: string
type: string | undefined
bits: (string | Blob | ArrayBuffer | ArrayBufferView)[]
constructor(
parts: (string | Blob | ArrayBuffer | ArrayBufferView)[],
name: string,
properties: FilePropertyBag
) {
this.bits = parts
this.name = name
this.type = properties.type
}
}
globalAny.Blob = class MockBlob {
name: string
bits: (string | Blob | ArrayBuffer | ArrayBufferView)[]
constructor(
parts: (string | Blob | ArrayBuffer | ArrayBufferView)[],
name: string,
properties: BlobPropertyBag
) {
this.bits = parts
this.name = name
}
}
globalAny.FileReaderSync = class MockFileReaderSync {
// tslint:disable-next-line:no-empty
readAsArrayBuffer(blob: Blob) {}
// tslint:disable-next-line:no-empty
readAsBinaryString(blob: Blob) {}
// tslint:disable-next-line:no-empty
readAsText(blob: Blob) {}
// tslint:disable-next-line:no-empty
readAsDataUrl(blob: Blob) {}
}
const reader = new globalAny.FileReaderSync()
globalAny.FileReader = class MockFileReader {
// tslint:disable-next-line:no-empty
readAsText(blob: Blob) {}
}