Skip to content

Commit 1baea2c

Browse files
committed
test: mock file object from MDN example
1 parent fa7251f commit 1baea2c

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

packages/util-body-length-browser/src/calculateBodyLength.spec.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,18 @@ describe(calculateBodyLength.name, () => {
1919
it("should handle TypedArray inputs", () => {
2020
expect(calculateBodyLength(typedArray)).toEqual(1);
2121
});
22+
23+
it("should handle File object", () => {
24+
// Mock File Object https://developer.mozilla.org/en-US/docs/Web/API/File/File#example
25+
const lastModifiedDate = new Date();
26+
const mockFileObject = {
27+
lastModified: lastModifiedDate.getTime(),
28+
lastModifiedDate,
29+
name: "foo.txt",
30+
size: 3,
31+
type: "text/plain",
32+
webkitRelativePath: "",
33+
};
34+
expect(calculateBodyLength(mockFileObject)).toEqual(mockFileObject.size);
35+
});
2236
});

0 commit comments

Comments
 (0)