Skip to content

Commit 1112f3f

Browse files
authored
Update unit tests to follow team jest standards (#25)
1 parent a7cab3a commit 1112f3f

File tree

8 files changed

+28
-7
lines changed

8 files changed

+28
-7
lines changed

.changeset/spotty-carpets-give.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"aws-sdk-js-codemod": patch
3+
---
4+
5+
Update unit tests to follow team jest standards

.eslintrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
"simple-import-sort/imports": "error",
88
"simple-import-sort/exports": "error"
99
},
10-
"ignorePatterns": ["__testfixtures__"]
10+
"ignorePatterns": ["__fixtures__"]
1111
}

.prettierignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__testfixtures__
1+
__fixtures__

src/transforms/v2-to-v3/__tests__/transformer.spec.ts

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { readdirSync, readFileSync } from "fs";
2+
import { runInlineTest } from "jscodeshift/dist/testUtils";
3+
import { join } from "path";
4+
5+
import transformer from "./transformer";
6+
7+
describe("v2-to-v3", () => {
8+
const fixtureDir = join(__dirname, "__fixtures__");
9+
const testFilePrefixes = readdirSync(fixtureDir)
10+
.filter((fileName) => fileName.endsWith(".input.ts"))
11+
.map((fileName) => fileName.replace(".input.ts", ""));
12+
13+
it.each(testFilePrefixes)(`transforms correctly using "%s" data`, (testFilePrefix) => {
14+
const path = join(fixtureDir, testFilePrefix + `.input.ts`);
15+
const source = readFileSync(path, "utf8");
16+
const input = { path, source };
17+
const expectedOutput = readFileSync(join(fixtureDir, testFilePrefix + `.output.ts`), "utf8");
18+
runInlineTest(transformer, null, input, expectedOutput);
19+
});
20+
});

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
"resolveJsonModule": true,
88
"rootDir": "src"
99
},
10-
"exclude": ["**/dist/**", "**/__tests__/**", "**/__testfixtures__/**"]
10+
"exclude": ["**/dist/**", "**/__fixtures__/**"]
1111
}

0 commit comments

Comments
 (0)