Forum

render.onload test cases coverage on file change event

0
Topic starter

render.onload test cases coverage on file change event

This topic was modified 7 months ago 2 times by kishan.pitroda
Topic Tags
1 Answer
0
Topic starter
let mockFileReader = {
    onload: jest.fn(),
    readAsText: jest.fn().mockImplementation(function (this: FileReader, file: Blob) {
        if (this.onload) {
            const event = {
                target: {
                    result: 'Full Name,Email Address,Full phone number,Title,Organization Name\nJohn Doe,john@example.com,+123456789,Manager,Example Inc.',
                },
            } as ProgressEvent<FileReader>;
            this.onload(event);
        }
    }),
};

global.FileReader = jest.fn().mockImplementation(() => mockFileReader) as any;
This post was modified 6 months ago by Lps75