Skip to content
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
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"generate:tests": "tsx scripts/generateNewClientTests",
"lint": "biome lint --write",
"release": "tsx scripts/testUpdatedIdentifiers && yarn build && changeset publish",
"test": "vitest"
"test": "node --import tsx --test src/**/*.spec.ts"
},
"dependencies": {
"jscodeshift": "17.1.1"
Expand All @@ -52,8 +52,7 @@
"@types/node": "^16.18.101",
"aws-sdk": "2.1692.0",
"tsx": "^4.7.1",
"typescript": "~5.7.2",
"vitest": "^3.0.3"
"typescript": "~5.7.2"
},
"engines": {
"node": ">=16.0.0"
Expand Down
44 changes: 27 additions & 17 deletions src/transforms/v2-to-v3/client-names/getV3ClientName.spec.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,35 @@
import { describe, expect, it } from "vitest";
import { strictEqual, throws } from "node:assert";
import { describe, it } from "node:test";

import { CLIENT_NAMES_MAP } from "../config";
import { getV3ClientName } from "./getV3ClientName";

describe(getV3ClientName.name, () => {
it.each(Object.entries(CLIENT_NAMES_MAP))("getV3ClientName('%s') === '%s'", (input, output) => {
expect(getV3ClientName(input)).toBe(output);
});
for (const [input, output] of Object.entries(CLIENT_NAMES_MAP)) {
it(`getV3ClientName('${input}') === '${output}'`, () => {
strictEqual(getV3ClientName(input), output);
});
}

it.each(["ImportExport", "MobileAnalytics", "SimpleDB"])(
"throws for deprecated client '%s'",
(deprecatedClient) => {
expect(() => {
getV3ClientName(deprecatedClient);
}).toThrow(new Error(`Client '${deprecatedClient}' is either deprecated or newly added.`));
}
);
for (const deprecatedClient of ["ImportExport", "MobileAnalytics", "SimpleDB"]) {
it(`throws for deprecated client '${deprecatedClient}'`, () => {
throws(
() => {
getV3ClientName(deprecatedClient);
},
new Error(`Client '${deprecatedClient}' is either deprecated or newly added.`)
);
});
}

it.each(["UNDEFINED", "NULL", "UNKNOWN"])("throws for unknown client '%s'", (unknownClient) => {
expect(() => {
getV3ClientName(unknownClient);
}).toThrow(new Error(`Client '${unknownClient}' is either deprecated or newly added.`));
});
for (const unknownClient of ["UNDEFINED", "NULL", "UNKNOWN"]) {
it(`throws for unknown client '${unknownClient}'`, () => {
throws(
() => {
getV3ClientName(unknownClient);
},
new Error(`Client '${unknownClient}' is either deprecated or newly added.`)
);
});
}
});
Original file line number Diff line number Diff line change
@@ -1,28 +1,35 @@
import { describe, expect, it } from "vitest";
import { strictEqual, throws } from "node:assert";
import { describe, it } from "node:test";

import { CLIENT_PACKAGE_NAMES_MAP } from "../config";
import { getV3ClientPackageName } from "./getV3ClientPackageName";

describe(getV3ClientPackageName.name, () => {
it.each(Object.entries(CLIENT_PACKAGE_NAMES_MAP))(
"getClientName('%s') === '%s'",
(input, output) => {
expect(getV3ClientPackageName(input)).toBe(`@aws-sdk/${output}`);
}
);
for (const [input, output] of Object.entries(CLIENT_PACKAGE_NAMES_MAP)) {
it("getClientName('%s') === '%s'", () => {
strictEqual(getV3ClientPackageName(input), `@aws-sdk/${output}`);
});
}

it.each(["ImportExport", "MobileAnalytics", "SimpleDB"])(
"throws for deprecated client '%s'",
(deprecatedClient) => {
expect(() => {
getV3ClientPackageName(deprecatedClient);
}).toThrow(new Error(`Client '${deprecatedClient}' is either deprecated or newly added.`));
}
);
for (const deprecatedClient of ["ImportExport", "MobileAnalytics", "SimpleDB"]) {
it("throws for deprecated client '%s'", () => {
throws(
() => {
getV3ClientPackageName(deprecatedClient);
},
new Error(`Client '${deprecatedClient}' is either deprecated or newly added.`)
);
});
}

it.each(["UNDEFINED", "NULL", "UNKNOWN"])("throws for unknown client '%s'", (unknownClient) => {
expect(() => {
getV3ClientPackageName(unknownClient);
}).toThrow(new Error(`Client '${unknownClient}' is either deprecated or newly added.`));
});
for (const unknownClient of ["UNDEFINED", "NULL", "UNKNOWN"]) {
it("throws for unknown client '%s'", () => {
throws(
() => {
getV3ClientPackageName(unknownClient);
},
new Error(`Client '${unknownClient}' is either deprecated or newly added.`)
);
});
}
});
47 changes: 26 additions & 21 deletions src/transforms/v2-to-v3/transformer.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { strictEqual } from "node:assert";
import { readdirSync } from "node:fs";
import { readFile } from "node:fs/promises";
import { join } from "node:path";
import { describe, it } from "node:test";
import jscodeshift from "jscodeshift";
import { describe, expect, it } from "vitest";

import transform from "./transformer";

Expand Down Expand Up @@ -34,25 +35,29 @@ describe("v2-to-v3", () => {
return { input, outputCode };
};

describe.each(fixtureSubDirs)("%s", (subDir) => {
const subDirPath = join(fixtureDir, subDir);
it.concurrent.each(getTestFileMetadata(subDirPath))(
"transforms: %s.%s",
async (filePrefix, fileExtension) => {
const { input, outputCode } = await getTestMetadata(subDirPath, filePrefix, fileExtension);

const output = await transform(input, {
j: jscodeshift,
jscodeshift,
// biome-ignore lint/suspicious/noEmptyBlockStatements: test helper
stats: () => {},
// biome-ignore lint/suspicious/noEmptyBlockStatements: test helper
report: () => {},
for (const subDir of fixtureSubDirs) {
describe(subDir, () => {
const subDirPath = join(fixtureDir, subDir);
for (const [filePrefix, fileExtension] of getTestFileMetadata(subDirPath)) {
it(`transforms: ${filePrefix}.${fileExtension}`, { concurrency: true }, async () => {
const { input, outputCode } = await getTestMetadata(
subDirPath,
filePrefix,
fileExtension
);

const output = await transform(input, {
j: jscodeshift,
jscodeshift,
// biome-ignore lint/suspicious/noEmptyBlockStatements: test helper
stats: () => {},
// biome-ignore lint/suspicious/noEmptyBlockStatements: test helper
report: () => {},
});

strictEqual(output.trim(), outputCode.trim());
});

expect(output.trim()).toEqual(outputCode.trim());
},
100000
);
});
}
});
}
});
13 changes: 8 additions & 5 deletions src/transforms/v2-to-v3/utils/isTypeScriptFile.spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import { describe, expect, it } from "vitest";
import { strictEqual } from "node:assert";
import { describe, it } from "node:test";

import { isTypeScriptFile } from "./isTypeScriptFile";

describe(isTypeScriptFile.name, () => {
it.each([
for (const [output, input] of [
[true, "foo.ts"],
[true, "foo.tsx"],
[false, "foo.js"],
[false, "foo.jsx"],
])("should return %b for %s", (output, input) => {
expect(isTypeScriptFile(input)).toBe(output);
});
] as const) {
it(`should return ${output} for ${input}`, () => {
strictEqual(isTypeScriptFile(input), output);
});
}
});
7 changes: 0 additions & 7 deletions vitest.config.mjs

This file was deleted.

Loading
Loading