This repository has been archived by the owner on Jul 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(test): Migrating from tape to Node.js test runner (#52)
- Loading branch information
Showing
5 changed files
with
104 additions
and
130 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,21 +1,20 @@ | ||
// Import Third-party Dependencies | ||
import test from "tape"; | ||
// Import Node.js Dependencies | ||
import { describe, test } from "node:test"; | ||
import assert from "node:assert"; | ||
|
||
// Import Internal Dependencies | ||
import { closestSpdxLicenseID } from "../src/licenses.js"; | ||
|
||
// Check everytruthy | ||
test("it should return the given LicenseID if no record match", (tape) => { | ||
tape.same(closestSpdxLicenseID("foooobar"), "foooobar"); | ||
tape.end(); | ||
}); | ||
describe("Check everytruthy", () => { | ||
test("it should return the given LicenseID if no record match", () => { | ||
assert.equal(closestSpdxLicenseID("foooobar"), "foooobar"); | ||
}); | ||
|
||
test("it should fix 'BSD 3-Clause' to 'BSD-3-Clause'", (tape) => { | ||
tape.same(closestSpdxLicenseID("BSD 3-Clause"), "BSD-3-Clause"); | ||
tape.end(); | ||
}); | ||
test("it should fix 'BSD 3-Clause' to 'BSD-3-Clause'", () => { | ||
assert.equal(closestSpdxLicenseID("BSD 3-Clause"), "BSD-3-Clause"); | ||
}); | ||
|
||
test("it should not fix 'BSD 3 Clause' because the distance is greater than one", (tape) => { | ||
tape.same(closestSpdxLicenseID("BSD 3 Clause"), "BSD 3 Clause"); | ||
tape.end(); | ||
test("it should not fix 'BSD 3 Clause' because the distance is greater than one", () => { | ||
assert.equal(closestSpdxLicenseID("BSD 3 Clause"), "BSD 3 Clause"); | ||
}); | ||
}); |
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,21 @@ | ||
// Import Third-party Dependencies | ||
import test from "tape"; | ||
// Import Node.js Dependencies | ||
import { test } from "node:test"; | ||
import assert from "node:assert"; | ||
|
||
// Import Internal Dependencies | ||
import { searchSpdxLicenseId } from "../index.js"; | ||
|
||
test("search for Apache 2.0 license", (tape) => { | ||
test("search for Apache 2.0 license", () => { | ||
const result = searchSpdxLicenseId("Apache License 2.0"); | ||
tape.strictEqual(result, "Apache-2.0"); | ||
|
||
tape.end(); | ||
assert.strictEqual(result, "Apache-2.0"); | ||
}); | ||
|
||
test("search for Artistic 1.0 license", (tape) => { | ||
test("search for Artistic 1.0 license", () => { | ||
const result = searchSpdxLicenseId("Artistic License 1.0"); | ||
tape.strictEqual(result, "Artistic-1.0"); | ||
|
||
tape.end(); | ||
assert.strictEqual(result, "Artistic-1.0"); | ||
}); | ||
|
||
test("it should return null if there is no license matching name", (tape) => { | ||
test("it should return null if there is no license matching name", () => { | ||
const result = searchSpdxLicenseId("not a license"); | ||
tape.strictEqual(result, null); | ||
|
||
tape.end(); | ||
assert.strictEqual(result, null); | ||
}); |
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,90 +1,80 @@ | ||
// Import Third-party Dependencies | ||
import test from "tape"; | ||
// Import Node.js Dependencies | ||
import { describe, test } from "node:test"; | ||
import assert from "node:assert"; | ||
|
||
// Import Internal Dependencies | ||
import { checkEveryTruthy, checkSomeTruthy, checkSpdx, createSpdxLink } from "../src/utils.js"; | ||
|
||
// Check everytruthy | ||
test("check a single true is true", (tape) => { | ||
tape.same(checkEveryTruthy(true), true); | ||
tape.end(); | ||
}); | ||
describe("Check everytruthy", () => { | ||
test("check a single true is true", () => { | ||
assert.equal(checkEveryTruthy(true), true); | ||
}); | ||
|
||
test("check multiple true booleans are true", (tape) => { | ||
tape.same(checkEveryTruthy(true, true, true), true); | ||
tape.end(); | ||
}); | ||
test("check multiple true booleans are true", () => { | ||
assert.equal(checkEveryTruthy(true, true, true), true); | ||
}); | ||
|
||
test("check that a single false is false", (tape) => { | ||
tape.same(checkEveryTruthy(false), false); | ||
tape.end(); | ||
}); | ||
test("check that a single false is false", () => { | ||
assert.equal(checkEveryTruthy(false), false); | ||
}); | ||
|
||
test("ensure that one false will result in a false return", (tape) => { | ||
tape.same(checkEveryTruthy(true, false), false); | ||
tape.end(); | ||
test("ensure that one false will result in a false return", () => { | ||
assert.equal(checkEveryTruthy(true, false), false); | ||
}); | ||
}); | ||
|
||
// check someTruthy | ||
test("check a single true is true", (tape) => { | ||
tape.same(checkSomeTruthy(true), true); | ||
tape.end(); | ||
}); | ||
describe("check someTruthy", () => { | ||
test("check a single true is true", () => { | ||
assert.equal(checkSomeTruthy(true), true); | ||
}); | ||
|
||
test("check multiple true booleans are true", (tape) => { | ||
tape.same(checkSomeTruthy(true, true, true), true); | ||
tape.end(); | ||
}); | ||
test("check multiple true booleans are true", () => { | ||
assert.equal(checkSomeTruthy(true, true, true), true); | ||
}); | ||
|
||
test("check that a single false is false", (tape) => { | ||
tape.same(checkSomeTruthy(false), false); | ||
tape.end(); | ||
}); | ||
test("check that a single false is false", () => { | ||
assert.equal(checkSomeTruthy(false), false); | ||
}); | ||
|
||
test("ensure that one false will result in a true return", (tape) => { | ||
tape.same(checkSomeTruthy(true, false), true); | ||
tape.end(); | ||
}); | ||
test("ensure that one false will result in a true return", () => { | ||
assert.equal(checkSomeTruthy(true, false), true); | ||
}); | ||
|
||
test("create an MIT SPDX link", (tape) => { | ||
const link = createSpdxLink("MIT"); | ||
test("create an MIT SPDX link", () => { | ||
const link = createSpdxLink("MIT"); | ||
|
||
tape.strictEqual(link, "https://spdx.org/licenses/MIT.html#licenseText"); | ||
tape.end(); | ||
assert.strictEqual(link, "https://spdx.org/licenses/MIT.html#licenseText"); | ||
}); | ||
}); | ||
|
||
// checkSpdx | ||
test("test with MIT license", (tape) => { | ||
const mitLicense = checkSpdx("MIT"); | ||
tape.same(mitLicense, { | ||
osi: true, | ||
fsf: true, | ||
fsfAndOsi: true, | ||
includesDeprecated: false | ||
describe("checkSpdx", () => { | ||
test("test with MIT license", () => { | ||
const mitLicense = checkSpdx("MIT"); | ||
assert.deepEqual(mitLicense, { | ||
osi: true, | ||
fsf: true, | ||
fsfAndOsi: true, | ||
includesDeprecated: false | ||
}); | ||
}); | ||
tape.end(); | ||
}); | ||
|
||
test("test with a deprecated license", (tape) => { | ||
const deprecatedLicense = checkSpdx("AGPL-1.0"); | ||
tape.same(deprecatedLicense, { | ||
osi: false, | ||
fsf: true, | ||
fsfAndOsi: false, | ||
includesDeprecated: true | ||
test("test with a deprecated license", () => { | ||
const deprecatedLicense = checkSpdx("AGPL-1.0"); | ||
assert.deepEqual(deprecatedLicense, { | ||
osi: false, | ||
fsf: true, | ||
fsfAndOsi: false, | ||
includesDeprecated: true | ||
}); | ||
}); | ||
tape.end(); | ||
}); | ||
|
||
test("test with a broken license", (tape) => { | ||
const brokenLicense = checkSpdx("wrong"); | ||
tape.same(brokenLicense, { | ||
osi: false, | ||
fsf: false, | ||
fsfAndOsi: false, | ||
includesDeprecated: false | ||
test("test with a broken license", () => { | ||
const brokenLicense = checkSpdx("wrong"); | ||
assert.deepEqual(brokenLicense, { | ||
osi: false, | ||
fsf: false, | ||
fsfAndOsi: false, | ||
includesDeprecated: false | ||
}); | ||
}); | ||
tape.end(); | ||
}); | ||
|
||
|