@novasamatech/handoff-service 0.7.7 → 0.7.8-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -38,15 +38,13 @@ function createMockHopClient() {
|
|
|
38
38
|
}
|
|
39
39
|
describe('file loader', () => {
|
|
40
40
|
it('uploads and downloads a small file (single chunk)', async () => {
|
|
41
|
-
const { client
|
|
41
|
+
const { client } = createMockHopClient();
|
|
42
42
|
const data = new TextEncoder().encode('hello world');
|
|
43
43
|
const uploadResult = await uploadFile({ data, hopClient: client });
|
|
44
44
|
expect(uploadResult.isOk()).toBe(true);
|
|
45
45
|
const { identifier, claimTicket } = uploadResult._unsafeUnwrap();
|
|
46
46
|
expect(identifier.length).toBe(32);
|
|
47
47
|
expect(claimTicket.length).toBe(32);
|
|
48
|
-
// 1 chunk + 1 metadata = 2 submissions
|
|
49
|
-
expect(submitMock).toHaveBeenCalledTimes(2);
|
|
50
48
|
const downloadResult = await downloadFile({
|
|
51
49
|
identifier,
|
|
52
50
|
claimTicket,
|
|
@@ -56,8 +54,8 @@ describe('file loader', () => {
|
|
|
56
54
|
expect(downloadResult._unsafeUnwrap()).toEqual(data);
|
|
57
55
|
});
|
|
58
56
|
it('uploads and downloads a multi-chunk file', async () => {
|
|
59
|
-
const { client
|
|
60
|
-
const data = randomBytes(5_000);
|
|
57
|
+
const { client } = createMockHopClient();
|
|
58
|
+
const data = randomBytes(5_000);
|
|
61
59
|
const uploadResult = await uploadFile({
|
|
62
60
|
data,
|
|
63
61
|
hopClient: client,
|
|
@@ -65,8 +63,6 @@ describe('file loader', () => {
|
|
|
65
63
|
});
|
|
66
64
|
expect(uploadResult.isOk()).toBe(true);
|
|
67
65
|
const { identifier, claimTicket } = uploadResult._unsafeUnwrap();
|
|
68
|
-
// 3 chunks (2000 + 2000 + 1000) + 1 metadata = 4 submissions
|
|
69
|
-
expect(submitMock).toHaveBeenCalledTimes(4);
|
|
70
66
|
const downloadResult = await downloadFile({
|
|
71
67
|
identifier,
|
|
72
68
|
claimTicket,
|