Skip to main content
zerotal

Documentation


Documentation / zerotal / testing / fakeFile

Variable: fakeFile

const fakeFile: object

Defined in: packages/testing/src/fakeFile.ts:23

Type Declaration

create()

create(name, content?, type?): File

A file with exactly the contents you give it.

Parameters

name

string

Filename sent with the upload.

content?

string | Uint8Array<ArrayBufferLike>

File contents; a string is encoded as UTF-8.

type?

string = "text/plain"

MIME type declared for the part.

Returns

File

sized()

sized(name, size, type?): File

A file of size bytes, for exercising size limits. The contents are filler, so use image or pdf when the bytes have to be recognisable.

Parameters

name

string

size

number

type?

string = "application/octet-stream"

Returns

File

Example

// Over a 2 MB limit
fakeFile.sized('huge.bin', 3 * 1024 * 1024);

image()

image(name?, options?): File

A valid PNG image of the given dimensions.

Parameters

name?

string = "image.png"

Filename sent with the upload.

options?
width?

number

Pixel width (default 10).

height?

number

Pixel height (default 10).

Returns

File

Example

fakeFile.image('avatar.png', { width: 64, height: 64 });

jpeg()

jpeg(name?): File

A minimal but structurally valid JPEG.

Parameters

name?

string = "image.jpg"

Returns

File

gif()

gif(name?): File

A minimal GIF89a image.

Parameters

name?

string = "image.gif"

Returns

File

pdf()

pdf(name?): File

A minimal one-page PDF.

Parameters

name?

string = "document.pdf"

Returns

File