@sprucelabs/spruce-file-utils 16.0.4 → 16.0.6
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.
@@ -44,12 +44,13 @@ export default class MockChunkingUploader extends AbstractEventEmitter {
|
|
44
44
|
}
|
45
45
|
upload(options) {
|
46
46
|
return __awaiter(this, void 0, void 0, function* () {
|
47
|
+
const { fileName } = options;
|
47
48
|
this.lastUploadOptions = options;
|
48
49
|
this.currentResponse++;
|
49
|
-
this.lastUploadResponse = this.getCurrentResponse();
|
50
|
-
if (this.nameToSlow ===
|
50
|
+
this.lastUploadResponse = this.getCurrentResponse(fileName);
|
51
|
+
if (this.nameToSlow === fileName) {
|
51
52
|
yield new Promise((r) => {
|
52
|
-
MockChunkingUploader.setTimeout(() => r(undefined),
|
53
|
+
MockChunkingUploader.setTimeout(() => r(undefined), 500);
|
53
54
|
});
|
54
55
|
}
|
55
56
|
return {
|
@@ -57,14 +58,14 @@ export default class MockChunkingUploader extends AbstractEventEmitter {
|
|
57
58
|
};
|
58
59
|
});
|
59
60
|
}
|
60
|
-
getCurrentResponse() {
|
61
|
+
getCurrentResponse(fileName) {
|
61
62
|
var _a;
|
62
63
|
if (this.fakedResponses.length > 0) {
|
63
64
|
return this.fakedResponses[this.currentResponse];
|
64
65
|
}
|
65
66
|
return ((_a = this.fakedResponse) !== null && _a !== void 0 ? _a : {
|
66
67
|
id: generateId(),
|
67
|
-
name: generateId(),
|
68
|
+
name: fileName !== null && fileName !== void 0 ? fileName : generateId(),
|
68
69
|
type: 'image/png',
|
69
70
|
uri: generateId(),
|
70
71
|
});
|
@@ -36,25 +36,26 @@ class MockChunkingUploader extends mercury_event_emitter_1.AbstractEventEmitter
|
|
36
36
|
this.fakedResponse = options;
|
37
37
|
}
|
38
38
|
async upload(options) {
|
39
|
+
const { fileName } = options;
|
39
40
|
this.lastUploadOptions = options;
|
40
41
|
this.currentResponse++;
|
41
|
-
this.lastUploadResponse = this.getCurrentResponse();
|
42
|
-
if (this.nameToSlow ===
|
42
|
+
this.lastUploadResponse = this.getCurrentResponse(fileName);
|
43
|
+
if (this.nameToSlow === fileName) {
|
43
44
|
await new Promise((r) => {
|
44
|
-
MockChunkingUploader.setTimeout(() => r(undefined),
|
45
|
+
MockChunkingUploader.setTimeout(() => r(undefined), 500);
|
45
46
|
});
|
46
47
|
}
|
47
48
|
return {
|
48
49
|
file: this.lastUploadResponse,
|
49
50
|
};
|
50
51
|
}
|
51
|
-
getCurrentResponse() {
|
52
|
+
getCurrentResponse(fileName) {
|
52
53
|
if (this.fakedResponses.length > 0) {
|
53
54
|
return this.fakedResponses[this.currentResponse];
|
54
55
|
}
|
55
56
|
return (this.fakedResponse ?? {
|
56
57
|
id: (0, test_utils_1.generateId)(),
|
57
|
-
name: (0, test_utils_1.generateId)(),
|
58
|
+
name: fileName ?? (0, test_utils_1.generateId)(),
|
58
59
|
type: 'image/png',
|
59
60
|
uri: (0, test_utils_1.generateId)(),
|
60
61
|
});
|