Skip to content

chore(deps-dev): bump jest to v27 #3130

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Jan 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 20 additions & 48 deletions lib/lib-storage/src/Upload.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe(Upload.name, () => {
Body: "this-is-a-sample-payload",
};

it("correctly exposes the event emitter API", (done) => {
it("correctly exposes the event emitter API", () => {
const upload = new Upload({
params,
client: new S3({}),
Expand All @@ -72,11 +72,9 @@ describe(Upload.name, () => {
expect(upload.eventNames).toBeDefined();
expect(upload.off).toBeDefined();
expect(upload.on).toBeDefined();

done();
});

it("should upload using PUT when empty buffer", async (done) => {
it("should upload using PUT when empty buffer", async () => {
const buffer = Buffer.from("");
const actionParams = { ...params, Body: buffer };
const upload = new Upload({
Expand All @@ -101,11 +99,9 @@ describe(Upload.name, () => {
expect(completeMultipartMock).toHaveBeenCalledTimes(0);
// no tags were passed.
expect(putObjectTaggingMock).toHaveBeenCalledTimes(0);

done();
});

it("should upload using PUT when empty stream", async (done) => {
it("should upload using PUT when empty stream", async () => {
const stream = new Readable({});
stream.push(null);
const actionParams = { ...params, Body: stream };
Expand All @@ -131,11 +127,9 @@ describe(Upload.name, () => {
expect(completeMultipartMock).toHaveBeenCalledTimes(0);
// no tags were passed.
expect(putObjectTaggingMock).toHaveBeenCalledTimes(0);

done();
});

it("should upload using PUT when parts are smaller than one part", async (done) => {
it("should upload using PUT when parts are smaller than one part", async () => {
const upload = new Upload({
params,
client: new S3({}),
Expand All @@ -158,11 +152,9 @@ describe(Upload.name, () => {
expect(completeMultipartMock).toHaveBeenCalledTimes(0);
// no tags were passed.
expect(putObjectTaggingMock).toHaveBeenCalledTimes(0);

done();
});

it("should upload using PUT when parts are smaller than one part stream", async (done) => {
it("should upload using PUT when parts are smaller than one part stream", async () => {
const streamBody = Readable.from(
(function* () {
yield params.Body;
Expand Down Expand Up @@ -190,11 +182,9 @@ describe(Upload.name, () => {
expect(completeMultipartMock).toHaveBeenCalledTimes(0);
// no tags were passed.
expect(putObjectTaggingMock).toHaveBeenCalledTimes(0);

done();
});

it("should upload using multi-part when parts are larger than part size", async (done) => {
it("should upload using multi-part when parts are larger than part size", async () => {
// create a string that's larger than 5MB.
const partSize = 1024 * 1024 * 5;
const largeBuffer = Buffer.from("#".repeat(partSize + 10));
Expand Down Expand Up @@ -256,10 +246,9 @@ describe(Upload.name, () => {
expect(putObjectTaggingMock).toHaveBeenCalledTimes(0);
// put was not called
expect(putObjectMock).toHaveBeenCalledTimes(0);
done();
});

it("should upload using multi-part when parts are larger than part size stream", async (done) => {
it("should upload using multi-part when parts are larger than part size stream", async () => {
// create a string that's larger than 5MB.
const largeBuffer = Buffer.from("#".repeat(DEFAULT_PART_SIZE + 10));
const firstBuffer = largeBuffer.subarray(0, DEFAULT_PART_SIZE);
Expand Down Expand Up @@ -325,10 +314,9 @@ describe(Upload.name, () => {
expect(putObjectTaggingMock).toHaveBeenCalledTimes(0);
// put was not called
expect(putObjectMock).toHaveBeenCalledTimes(0);
done();
});

it("should add tags to the object if tags have been added PUT", async (done) => {
it("should add tags to the object if tags have been added PUT", async () => {
const tags = [
{
Key: "k1",
Expand Down Expand Up @@ -358,11 +346,9 @@ describe(Upload.name, () => {
TagSet: tags,
},
});

done();
});

it("should add tags to the object if tags have been added multi-part", async (done) => {
it("should add tags to the object if tags have been added multi-part", async () => {
const largeBuffer = Buffer.from("#".repeat(DEFAULT_PART_SIZE + 10));
const actionParams = { ...params, Body: largeBuffer };
const tags = [
Expand Down Expand Up @@ -394,44 +380,35 @@ describe(Upload.name, () => {
TagSet: tags,
},
});

done();
});

it("should validate partsize", async (done) => {
it("should validate partsize", () => {
try {
const upload = new Upload({
new Upload({
params,
partSize: 6,
client: new S3({}),
});

//should not get here.
expect(1).toEqual(0);
fail();
} catch (error) {
expect(error).toBeDefined();
done();
}
});

it("should validate queue size", (done) => {
it("should validate queue size", () => {
try {
const upload = new Upload({
new Upload({
params,
queueSize: -1,
client: new S3({}),
});

//should not get here.
expect(1).toEqual(0);
fail();
} catch (error) {
expect(error).toBeDefined();
done();
}
done();
});

it("should provide progress updates", async (done) => {
it("should provide progress updates", async () => {
const upload = new Upload({
params,
client: new S3({}),
Expand All @@ -445,12 +422,11 @@ describe(Upload.name, () => {
part: 1,
total: 24,
});
done();
});
await upload.done();
});

it("should provide progress updates multi-part buffer", async (done) => {
it("should provide progress updates multi-part buffer", async () => {
const partSize = 1024 * 1024 * 5;
const largeBuffer = Buffer.from("#".repeat(partSize + 10));
const firstBuffer = largeBuffer.subarray(0, partSize);
Expand Down Expand Up @@ -480,10 +456,9 @@ describe(Upload.name, () => {
total: largeBuffer.byteLength,
});
expect(received.length).toBe(2);
done();
});

it("should provide progress updates multi-part stream", async (done) => {
it("should provide progress updates multi-part stream", async () => {
const partSize = 1024 * 1024 * 5;
const largeBuffer = Buffer.from("#".repeat(partSize + 10));
const streamBody = Readable.from(
Expand Down Expand Up @@ -517,10 +492,9 @@ describe(Upload.name, () => {
total: undefined,
});
expect(received.length).toBe(2);
done();
});

it("should provide progress updates empty buffer", async (done) => {
it("should provide progress updates empty buffer", async () => {
const buffer = Buffer.from("");
const actionParams = { ...params, Body: buffer };
const upload = new Upload({
Expand All @@ -541,10 +515,9 @@ describe(Upload.name, () => {
total: 0,
});
expect(received.length).toBe(1);
done();
});

it("should provide progress updates empty stream", async (done) => {
it("should provide progress updates empty stream", async () => {
const stream = Readable.from((function* () {})());
const actionParams = { ...params, Body: stream };
const upload = new Upload({
Expand All @@ -565,6 +538,5 @@ describe(Upload.name, () => {
total: 0,
});
expect(received.length).toBe(1);
done();
});
});
9 changes: 3 additions & 6 deletions lib/lib-storage/src/chunks/getChunkBuffer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe.only(getChunkBuffer.name, () => {
const getBuffer = (size: number) => Buffer.from("#".repeat(size));

describe("Buffer chunking", () => {
it("should come back with small sub buffers", async (done) => {
it("should come back with small sub buffers", async () => {
const chunklength = 100;
const totalLength = 1000;
const buffer = getBuffer(totalLength);
Expand All @@ -25,10 +25,9 @@ describe.only(getChunkBuffer.name, () => {
}

expect(chunkNum).toEqual(expectedNumberOfChunks);
done();
});

it("should come back with the last chunk the remainder size", async (done) => {
it("should come back with the last chunk the remainder size", async () => {
const chunklength = 1000;
const totalLength = 2200;
const buffer = getBuffer(totalLength);
Expand All @@ -46,10 +45,9 @@ describe.only(getChunkBuffer.name, () => {
expect(chunks[1].lastPart).toBe(undefined);
expect(byteLength(chunks[2].data)).toBe(totalLength % chunklength);
expect(chunks[2].lastPart).toBe(true);
done();
});

it("should come back with one chunk if it is a small buffer", async (done) => {
it("should come back with one chunk if it is a small buffer", async () => {
const chunklength = 1000;
const totalLength = 200;
const buffer = getBuffer(totalLength);
Expand All @@ -63,7 +61,6 @@ describe.only(getChunkBuffer.name, () => {
expect(chunks.length).toEqual(1);
expect(byteLength(chunks[0].data)).toBe(totalLength % chunklength);
expect(chunks[0].lastPart).toBe(true);
done();
});
});
});
9 changes: 3 additions & 6 deletions lib/lib-storage/src/chunks/getDataReadable.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe(chunkFromReadable.name, () => {
return chunks;
};

it("should return chunks of a specific size", async (done) => {
it("should return chunks of a specific size", async () => {
const chunks = await getChunks(58, 1, 20);

expect(chunks.length).toBe(3);
Expand All @@ -47,10 +47,9 @@ describe(chunkFromReadable.name, () => {
expect(byteLength(chunks[2].data)).toEqual(18);
expect(chunks[2].partNumber).toEqual(3);
expect(chunks[2].lastPart).toBe(true);
done();
});

it("should properly chunk a file", async (done) => {
it("should properly chunk a file", async () => {
const fileStream = fs.createReadStream(__dirname + "/sample.file");
const chunks: DataPart[] = [];
const chunker = chunkFromReadable<Readable>(fileStream, _6MB, getDataReadable);
Expand All @@ -62,10 +61,9 @@ describe(chunkFromReadable.name, () => {
expect(byteLength(chunks[0].data)).toEqual(byteLength(fileStream));
expect(chunks[0].partNumber).toEqual(1);
expect(chunks[0].lastPart).toBe(true);
done();
});

it("should properly chunk a large stream of unknown size", async (done) => {
it("should properly chunk a large stream of unknown size", async () => {
//should go into 11 chunks. Each with ~6mb and the last with 3mb
const chunks = await getChunks(_6MB / 2, 21, _6MB);

Expand All @@ -76,6 +74,5 @@ describe(chunkFromReadable.name, () => {
}
expect(byteLength(chunks[10].data)).toEqual(_6MB / 2);
expect(chunks[10].lastPart).toBe(true);
done();
});
});
10 changes: 3 additions & 7 deletions lib/lib-storage/src/chunks/getDataReadableStream.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,16 @@ describe("chunkFromReadable.name", () => {
return chunks;
};

it("should a single chunk if the stream is smaller than partsize", async (done) => {
it("should a single chunk if the stream is smaller than partsize", async () => {
const chunks = await getChunks(34, 2, 100);

expect(chunks.length).toBe(1);
expect(byteLength(chunks[0].data)).toEqual(68);
expect(chunks[0].partNumber).toEqual(1);
expect(chunks[0].lastPart).toBe(true);

done();
});

it("should return chunks of a specific size", async (done) => {
it("should return chunks of a specific size", async () => {
const chunks = await getChunks(58, 1, 20);

expect(chunks.length).toBe(3);
Expand All @@ -61,10 +59,9 @@ describe("chunkFromReadable.name", () => {
expect(byteLength(chunks[2].data)).toEqual(18);
expect(chunks[2].partNumber).toEqual(3);
expect(chunks[2].lastPart).toBe(true);
done();
});

it("should properly chunk a large stream of unknown size", async (done) => {
it("should properly chunk a large stream of unknown size", async () => {
const chunks = await getChunks(_6MB / 2, 21, _6MB);

expect(chunks.length).toEqual(11);
Expand All @@ -74,6 +71,5 @@ describe("chunkFromReadable.name", () => {
}
expect(byteLength(chunks[10].data)).toEqual(_6MB / 2);
expect(chunks[10].lastPart).toBe(true);
done();
});
});
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"@mixer/parallel-prettier": "^2.0.1",
"@types/chai-as-promised": "^7.1.2",
"@types/fs-extra": "^8.0.1",
"@types/jest": "^26.0.4",
"@types/jest": "27.4.0",
"@typescript-eslint/eslint-plugin": "4.30.0",
"@typescript-eslint/parser": "4.30.0",
"async": "3.2.1",
Expand All @@ -79,7 +79,7 @@
"generate-changelog": "^1.7.1",
"husky": "^4.2.3",
"jasmine-core": "^3.5.0",
"jest": "^26.1.0",
"jest": "27.4.5",
"jmespath": "^0.15.0",
"json5": "^2.2.0",
"karma": "^5.1.0",
Expand All @@ -99,7 +99,7 @@
"prettier": "2.5.1",
"puppeteer": "^5.1.0",
"strip-comments": "2.0.1",
"ts-jest": "^26.4.1",
"ts-jest": "27.1.2",
"ts-loader": "^7.0.5",
"ts-mocha": "8.0.0",
"ts-node": "^10.4.0",
Expand Down
1 change: 1 addition & 0 deletions packages/body-checksum-browser/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ const base = require("../../jest.config.base.js");

module.exports = {
...base,
testEnvironment: "jsdom",
};
1 change: 1 addition & 0 deletions packages/chunked-blob-reader-native/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ const base = require("../../jest.config.base.js");

module.exports = {
...base,
testEnvironment: "jsdom",
};
1 change: 1 addition & 0 deletions packages/chunked-blob-reader/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ const base = require("../../jest.config.base.js");

module.exports = {
...base,
testEnvironment: "jsdom",
};
Loading