(overrides = {})
| 7 | * @returns {File} |
| 8 | */ |
| 9 | export const buildFile = (overrides = {}) => { |
| 10 | const maxSizeInBytes = 10 * 1024 ** 2 |
| 11 | const { |
| 12 | name = faker.system.fileName(), |
| 13 | size = faker.datatype.number({ min: 1024, max: 1024 * 3 }), |
| 14 | type = MimeType.gif |
| 15 | } = overrides |
| 16 | |
| 17 | // Allocate an array the given size, but set a reasonable ceiling for testing |
| 18 | const file = new File(Buffer.alloc(Math.min(size, maxSizeInBytes)), name, { |
| 19 | type |
| 20 | }) |
| 21 | return file |
| 22 | } |
| 23 | |
| 24 | /** |
| 25 | * Builds a collection of `File` objects for testing |
no outgoing calls
no test coverage detected