| 1 |
import { readFile, fileReaderType } from '../fileUtils'; |
| 2 |
|
| 3 |
describe('readFile', () => { |
| 4 |
const file = new File(['File contents here'], 'testfile.txt'); |
| 5 |
|
| 6 |
test('text file', () => expect(readFile(file, fileReaderType.text)).resolves.toBe('File contents here')); |
| 7 |
|
| 8 |
test('dataURL file', () => |
| 9 |
expect(readFile(file, fileReaderType.dataURL)).resolves.toBe( |
| 10 |
'data:application/octet-stream;base64,RmlsZSBjb250ZW50cyBoZXJl' |
| 11 |
)); |
| 12 |
|
| 13 |
test('rejects on unknown type', () => expect(readFile(file, 'foo' as fileReaderType)).rejects.toBe('unknown type')); |
| 14 |
}); |