Skip to content

chore(deps-dev): bump jest to 28.1.1 #3732

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 4 commits into from
Jun 25, 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
38 changes: 29 additions & 9 deletions lib/lib-storage/src/Upload.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ jest.mock("@aws-sdk/client-s3", () => ({
}));

import { CompleteMultipartUploadCommandOutput, S3 } from "@aws-sdk/client-s3";
import { createHash } from "crypto";
import { Readable } from "stream";

import { Progress, Upload } from "./index";
Expand All @@ -76,6 +77,24 @@ describe(Upload.name, () => {
Body: "this-is-a-sample-payload",
};

expect.extend({
toHaveSameHashAsBuffer: (received: Uint8Array, expected: Uint8Array) => {
const receivedHash = createHash("sha256").update(received).digest("hex");
const expectHash = createHash("sha256").update(expected).digest("hex");
if (expectHash === receivedHash) {
return {
message: () => "received buffer has the correct hash",
pass: true,
};
} else {
return {
message: () => `received buffer hash is incorrect, expect ${expectHash}, got ${receivedHash}.`,
pass: false,
};
}
},
});

it("correctly exposes the event emitter API", () => {
const upload = new Upload({
params,
Expand Down Expand Up @@ -237,33 +256,30 @@ describe(Upload.name, () => {
params: actionParams,
client: new S3({}),
});

await upload.done();

expect(sendMock).toHaveBeenCalledTimes(4);
// create multipartMock is called correctly.
expect(createMultipartMock).toHaveBeenCalledTimes(1);
expect(createMultipartMock).toHaveBeenCalledWith({
...actionParams,
Body: undefined,
});

// upload parts is called correctly.
expect(uploadPartMock).toHaveBeenCalledTimes(2);
expect(uploadPartMock).toHaveBeenNthCalledWith(1, {
...actionParams,
Body: firstBuffer,
// @ts-ignore extended custom matcher
Body: expect.toHaveSameHashAsBuffer(firstBuffer),
PartNumber: 1,
UploadId: "mockuploadId",
});

expect(uploadPartMock).toHaveBeenNthCalledWith(2, {
...actionParams,
Body: secondBuffer,
// @ts-ignore extended custom matcher
Body: expect.toHaveSameHashAsBuffer(secondBuffer),
PartNumber: 2,
UploadId: "mockuploadId",
});

// complete multipart upload is called correctly.
expect(completeMultipartMock).toHaveBeenCalledTimes(1);
expect(completeMultipartMock).toHaveBeenLastCalledWith({
Expand Down Expand Up @@ -320,14 +336,16 @@ describe(Upload.name, () => {
expect(uploadPartMock).toHaveBeenCalledTimes(2);
expect(uploadPartMock).toHaveBeenNthCalledWith(1, {
...actionParams,
Body: firstBuffer,
// @ts-ignore extended custom matcher
Body: expect.toHaveSameHashAsBuffer(firstBuffer),
PartNumber: 1,
UploadId: "mockuploadId",
});

expect(uploadPartMock).toHaveBeenNthCalledWith(2, {
...actionParams,
Body: secondBuffer,
// @ts-ignore extended custom matcher
Body: expect.toHaveSameHashAsBuffer(secondBuffer),
PartNumber: 2,
UploadId: "mockuploadId",
});
Expand Down Expand Up @@ -418,6 +436,8 @@ describe(Upload.name, () => {
expect(putObjectTaggingMock).toHaveBeenCalledTimes(1);
expect(putObjectTaggingMock).toHaveBeenCalledWith({
...actionParams,
// @ts-ignore extended custom matcher
Body: expect.toHaveSameHashAsBuffer(largeBuffer),
Tagging: {
TagSet: tags,
},
Expand Down
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"@tsconfig/recommended": "1.0.1",
"@types/chai-as-promised": "^7.1.2",
"@types/fs-extra": "^8.0.1",
"@types/jest": "27.4.0",
"@types/jest": "28.1.3",
"@typescript-eslint/eslint-plugin": "5.28.0",
"@typescript-eslint/parser": "5.28.0",
"async": "3.2.4",
Expand All @@ -81,7 +81,8 @@
"generate-changelog": "^1.7.1",
"husky": "^4.2.3",
"jasmine-core": "^3.5.0",
"jest": "27.4.5",
"jest": "28.1.1",
"jest-environment-jsdom": "28.1.1",
"jmespath": "^0.15.0",
"json5": "^2.2.0",
"karma": "6.4.0",
Expand All @@ -102,7 +103,7 @@
"puppeteer": "^5.1.0",
"rimraf": "3.0.2",
"strip-comments": "2.0.1",
"ts-jest": "27.1.2",
"ts-jest": "28.0.5",
"ts-loader": "^7.0.5",
"ts-mocha": "10.0.0",
"ts-node": "^10.4.0",
Expand All @@ -126,7 +127,8 @@
"**/karma*/**",
"**/@types/mocha*",
"**/@types/mocha*/**",
"**/@aws-sdk/client-sso/**"
"**/@aws-sdk/client-sso/**",
"**/@babel/**"
]
},
"husky": {
Expand Down
2 changes: 1 addition & 1 deletion packages/middleware-retry/src/DefaultRateLimiter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe(DefaultRateLimiter.name, () => {

describe("getSendToken", () => {
beforeEach(() => {
jest.useFakeTimers("legacy");
jest.useFakeTimers({ legacyFakeTimers: true });
});

afterEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe("setConnectionTimeout", () => {
};

beforeEach(() => {
jest.useFakeTimers("legacy");
jest.useFakeTimers({ legacyFakeTimers: true });
setConnectionTimeout(clientRequest, reject, timeoutInMs);
});

Expand Down
2 changes: 1 addition & 1 deletion packages/util-waiter/src/createWaiter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { createWaiter } from "./createWaiter";

describe("createWaiter", () => {
beforeEach(() => {
jest.useFakeTimers("legacy");
jest.useFakeTimers({ legacyFakeTimers: true });
});

afterEach(() => {
Expand Down
2 changes: 1 addition & 1 deletion packages/util-waiter/src/utils/sleep.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { sleep } from "./sleep";

describe("Sleep Module", () => {
beforeEach(() => {
jest.useFakeTimers("legacy");
jest.useFakeTimers({ legacyFakeTimers: true });
});

afterEach(() => {
Expand Down
Loading