better mocking of FileReader and events

This commit is contained in:
alecmerdler 2017-03-11 17:45:36 -08:00
parent ade4216642
commit 7416534ab8
3 changed files with 35 additions and 20 deletions

View file

@ -8,9 +8,13 @@ declare const Untar: (uint8Array: Uint8Array) => void;
@Injectable(DataFileService.name)
export class DataFileServiceImpl implements DataFileService {
constructor(private fileReaderFactory: () => FileReader) {
}
public blobToString(blob: any, callback: (result: string) => void): void {
var reader: FileReader = new FileReader();
reader.onload = (event: Event) => callback(reader.result);
reader.onload = (event: Event) => callback(event.target['result']);
reader.readAsText(blob);
}