({
name = 'file.txt',
contents = '',
type = 'text/plain',
}: ReadableFileBuilderOptions = {})
| 454 | }; |
| 455 | |
| 456 | export function buildReadableFile({ |
| 457 | name = 'file.txt', |
| 458 | contents = '', |
| 459 | type = 'text/plain', |
| 460 | }: ReadableFileBuilderOptions = {}): File { |
| 461 | const file = buildFile(name, contents, type); |
| 462 | |
| 463 | Object.defineProperties(file, { |
| 464 | arrayBuffer: { |
| 465 | configurable: true, |
| 466 | value: () => Promise.resolve(encodeFileContents(contents)), |
| 467 | }, |
| 468 | text: { |
| 469 | configurable: true, |
| 470 | value: () => Promise.resolve(contents), |
| 471 | }, |
| 472 | }); |
| 473 | |
| 474 | return file; |
| 475 | } |
| 476 | |
| 477 | export function buildTextFile(name: string, contents: string): File { |
| 478 | return buildReadableFile({ name, contents, type: 'text/plain' }); |
no test coverage detected