generated from actions/javascript-action
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: migrate Jest to
node:test
(#961)
- Loading branch information
1 parent
6609e96
commit 80c0424
Showing
10 changed files
with
245 additions
and
2,916 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,32 @@ | ||
import { strict as assert } from "node:assert"; | ||
import { readFileSync } from "node:fs"; | ||
import { test, expect } from "@jest/globals"; | ||
import { test } from "node:test"; | ||
|
||
import buildCommitBody from "../buildCommitBody.js"; | ||
|
||
const report = JSON.parse(readFileSync(new URL("./fixtures/report.json", import.meta.url), "utf8")); | ||
|
||
test("buildCommitBody()", () => { | ||
expect(buildCommitBody(report)).toEqual(`Summary: | ||
assert.equal( | ||
buildCommitBody(report), | ||
`Summary: | ||
- Updated packages: 2 | ||
- Added packages: 1 | ||
- Removed packages: 1 | ||
Fixed vulnerabilities: | ||
- mocha: "Prototype Pollution" (https://npmjs.com/advisories/1179) | ||
`); | ||
`, | ||
); | ||
|
||
expect(buildCommitBody({ added: [], removed: [], updated: [], packageCount: 0, packageUrls: {} })) | ||
.toEqual(`Summary: | ||
assert.equal( | ||
buildCommitBody({ added: [], removed: [], updated: [], packageCount: 0, packageUrls: {} }), | ||
`Summary: | ||
- Updated packages: 0 | ||
- Added packages: 0 | ||
- Removed packages: 0 | ||
No fixed vulnerabilities. | ||
`); | ||
`, | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,34 @@ | ||
import { strict as assert } from "node:assert"; | ||
import path from "node:path"; | ||
import { test, expect } from "@jest/globals"; | ||
import { test } from "node:test"; | ||
|
||
import listPackages from "../listPackages.js"; | ||
|
||
const fixtures = new URL("./fixtures", import.meta.url).pathname; | ||
|
||
test("listPackages()", async () => { | ||
const packages = await listPackages({ silent: true }); | ||
expect(packages.size).not.toEqual(0); | ||
expect(packages.get("jest:jest")).toMatch(/^\d+\.\d+\.\d+$/u); | ||
expect(packages.get("@actions/core:@actions/core")).toMatch(/^\d+\.\d+\.\d+$/u); | ||
expect(packages.get("eslint/node_modules/eslint-scope:eslint-scope")).toMatch(/^\d+\.\d+\.\d+$/u); | ||
assert.notEqual(packages.size, 0); | ||
assert.match(String(packages.get("eslint:eslint")), /^\d+\.\d+\.\d+$/u); | ||
assert.match(String(packages.get("@actions/core:@actions/core")), /^\d+\.\d+\.\d+$/u); | ||
assert.match( | ||
String(packages.get("eslint/node_modules/eslint-scope:eslint-scope")), | ||
/^\d+\.\d+\.\d+$/u, | ||
); | ||
}); | ||
|
||
test("listPackages() with an empty package.json", async () => { | ||
const packages = await listPackages({ | ||
silent: true, | ||
cwd: path.join(fixtures, "empty_package.json"), | ||
}); | ||
expect(packages.size).toEqual(0); | ||
assert.equal(packages.size, 0); | ||
}); | ||
|
||
test("listPackages() with a package.json having no version", async () => { | ||
const packages = await listPackages({ | ||
silent: true, | ||
cwd: path.join(fixtures, "noversion_package.json"), | ||
}); | ||
expect(packages.size).toEqual(0); | ||
assert.equal(packages.size, 0); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
import { test, expect } from "@jest/globals"; | ||
import { strict as assert } from "node:assert"; | ||
import { test } from "node:test"; | ||
|
||
import npmArgs from "../npmArgs.js"; | ||
|
||
test("npmArgs() without arguments", () => { | ||
expect(npmArgs()).toEqual(["--ignore-scripts", "--no-progress"]); | ||
assert.deepEqual(npmArgs(), ["--ignore-scripts", "--no-progress"]); | ||
}); | ||
|
||
test("npmArgs() with arguments", () => { | ||
expect(npmArgs("a", "b")).toEqual(["a", "b", "--ignore-scripts", "--no-progress"]); | ||
assert.deepEqual(npmArgs("a", "b"), ["a", "b", "--ignore-scripts", "--no-progress"]); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,23 @@ | ||
import { test, expect } from "@jest/globals"; | ||
import { strict as assert } from "node:assert"; | ||
import { test } from "node:test"; | ||
|
||
import commaSeparatedList from "../commaSeparatedList.js"; | ||
|
||
test("commaSeparatedList()", () => { | ||
expect(commaSeparatedList("")).toEqual([]); | ||
expect(commaSeparatedList(" ")).toEqual([]); | ||
expect(commaSeparatedList(",")).toEqual([]); | ||
expect(commaSeparatedList(" , ")).toEqual([]); | ||
expect(commaSeparatedList("a,")).toEqual(["a"]); | ||
expect(commaSeparatedList("a,b")).toEqual(["a", "b"]); | ||
expect(commaSeparatedList("a ,b")).toEqual(["a", "b"]); | ||
expect(commaSeparatedList("a, b")).toEqual(["a", "b"]); | ||
expect(commaSeparatedList(",a, b")).toEqual(["a", "b"]); | ||
expect(commaSeparatedList("a, b,")).toEqual(["a", "b"]); | ||
expect(commaSeparatedList(" a, b, ")).toEqual(["a", "b"]); | ||
assert.deepEqual(commaSeparatedList(""), []); | ||
assert.deepEqual(commaSeparatedList(" "), []); | ||
assert.deepEqual(commaSeparatedList(","), []); | ||
assert.deepEqual(commaSeparatedList(" , "), []); | ||
assert.deepEqual(commaSeparatedList("a"), ["a"]); | ||
assert.deepEqual(commaSeparatedList("a,"), ["a"]); | ||
assert.deepEqual(commaSeparatedList(",a"), ["a"]); | ||
assert.deepEqual(commaSeparatedList("a,b"), ["a", "b"]); | ||
assert.deepEqual(commaSeparatedList("a ,b"), ["a", "b"]); | ||
assert.deepEqual(commaSeparatedList("a, b"), ["a", "b"]); | ||
assert.deepEqual(commaSeparatedList("a , b"), ["a", "b"]); | ||
assert.deepEqual(commaSeparatedList("a, b,"), ["a", "b"]); | ||
assert.deepEqual(commaSeparatedList("a , b,"), ["a", "b"]); | ||
assert.deepEqual(commaSeparatedList("a, b, "), ["a", "b"]); | ||
assert.deepEqual(commaSeparatedList("a , b, "), ["a", "b"]); | ||
assert.deepEqual(commaSeparatedList(" a, b,"), ["a", "b"]); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
import { test, expect } from "@jest/globals"; | ||
import { strict as assert } from "node:assert"; | ||
import { test } from "node:test"; | ||
|
||
import semverToNumber from "../semverToNumber.js"; | ||
|
||
test("semverToNumber()", () => { | ||
expect(semverToNumber("1.2.3")).toEqual(10203); | ||
expect(semverToNumber("0.0.3")).toEqual(3); | ||
expect(semverToNumber("0.9.3")).toEqual(903); | ||
expect(semverToNumber("0.10.3")).toEqual(1003); | ||
expect(semverToNumber("1.0.3")).toEqual(10003); | ||
expect(semverToNumber("1.2.4")).toEqual(10204); | ||
expect(semverToNumber("1.2.4-beta.1")).toEqual(10204); | ||
assert.equal(semverToNumber("1.2.3"), 10203); | ||
assert.equal(semverToNumber("0.0.3"), 3); | ||
assert.equal(semverToNumber("0.9.3"), 903); | ||
assert.equal(semverToNumber("0.10.3"), 1003); | ||
assert.equal(semverToNumber("1.0.3"), 10003); | ||
assert.equal(semverToNumber("1.2.4"), 10204); | ||
assert.equal(semverToNumber("1.2.4-beta.1"), 10204); | ||
}); |
Oops, something went wrong.