diff --git a/workspaces/vis-network/package.json b/workspaces/vis-network/package.json index 35008782..210f9853 100644 --- a/workspaces/vis-network/package.json +++ b/workspaces/vis-network/package.json @@ -7,7 +7,7 @@ "scripts": { "lint": "eslint src test", "lint:fix": "eslint --fix src test", - "test": "node --test test/", + "test": "node --test test/*.test.js", "test:c8": "c8 npm run test", "start": "npm run build && http-server ./dist", "build": "rimraf ./dist && node esbuild.config.js" @@ -32,4 +32,4 @@ "@nodesecure/flags": "^2.4.0", "@nodesecure/scanner": "^6.0.2" } -} +} \ No newline at end of file diff --git a/workspaces/vis-network/test/dataset-payload.json b/workspaces/vis-network/test/dataset-payload.json index af095da8..46988ad1 100644 --- a/workspaces/vis-network/test/dataset-payload.json +++ b/workspaces/vis-network/test/dataset-payload.json @@ -1,6 +1,6 @@ { "id": "abcde", - "rootDepencyName": "pkg1", + "rootDependencyName": "pkg1", "highlighted": { "contacts": [ { @@ -11,7 +11,7 @@ "js-x-ray" ] }, - { + { "name": "Rich Harris", "email": "rich.harris@gmail.com", "dependencies": [ @@ -34,6 +34,13 @@ }, "dependencies": { "pkg2": { + "metadata": { + "author": { + "name": "john papa" + }, + "maintainers": [], + "publishers": [] + }, "versions": { "1.0.3": { "usedBy": { @@ -51,17 +58,23 @@ ".json" ] }, - "license": { - "uniqueLicenseIds": [ - "Unlicense" - ] - }, + "licenses": [], + "uniqueLicenseIds": [ + "Unlicense" + ], "name": "pkg2", "version": "1.0.3" } } }, "pkg3": { + "metadata": { + "author": { + "name": "john wick" + }, + "maintainers": [], + "publishers": [] + }, "versions": { "3.4.0": { "id": 4, @@ -85,15 +98,21 @@ ".json" ] }, - "license": { - "uniqueLicenseIds": [ - "Licence1" - ] - } + "licenses": [], + "uniqueLicenseIds": [ + "Licence1" + ] } } }, "pkg1": { + "metadata": { + "author": { + "name": "john doe" + }, + "maintainers": [], + "publishers": [] + }, "versions": { "3.0.0": { "id": 0, @@ -114,15 +133,27 @@ ".json" ] }, - "license": "a string licence (should be unknown)", + "licenses": [ + { + "licenses": {}, + "spdx": { + "osi": true, + "fsf": true, + "fsfAndOsi": true, + "includesDeprecated": true + } + } + ], + "uniqueLicenseIds": [], "warnings": [] } } } }, - "version": "2.2.0", + "scannerVersion": "2.2.0", "warnings": [ "warning_01", "warning_02" - ] -} + ], + "vulnerabilityStrategy": "npm" +} \ No newline at end of file diff --git a/workspaces/vis-network/test/dataset.test.js b/workspaces/vis-network/test/dataset.test.js index 7eaa6590..c04ae50d 100644 --- a/workspaces/vis-network/test/dataset.test.js +++ b/workspaces/vis-network/test/dataset.test.js @@ -8,6 +8,14 @@ import { getDataSetPayload } from "./dataset.fixture.js"; const dataSetPayload = await getDataSetPayload(); +global.window = { + settings: { + config: { + showFriendlyDependencies: true + } + } +}; + test("NodeSecureDataSet.init with given payload", async() => { const nsDataSet = new NodeSecureDataSet(); await nsDataSet.init(dataSetPayload); @@ -57,21 +65,17 @@ test("NodeSecureDataSet.isHighlighted", async() => { test("NodeSecureDataSet.computeLicenses", () => { const nsDataSet = new NodeSecureDataSet(); - nsDataSet.computeLicense("MIT"); - assert.equal(Object.keys(nsDataSet.licenses).length, 1, "should have 1 license"); - assert.equal(nsDataSet.licenses.Unknown, 1, "should have 1 unknown license"); - - nsDataSet.computeLicense({ uniqueLicenseIds: ["MIT", "MIT", "RND"] }); + nsDataSet.computeLicense(["MIT", "MIT", "RND"]); assert.equal(Object.keys(nsDataSet.licenses).length, 3, "should have 3 licenses (MIT, RND & 1 unknown)"); assert.equal(nsDataSet.licenses.MIT, 2, "should have 2 MIT licenses"); }); test("NodeSecureDataSet.computeAuthors", () => { const nsDataSet = new NodeSecureDataSet(); - nsDataSet.computeAuthor({ name: "John Doe" }); + nsDataSet.computeAuthor({ name: "John Doe" }, "pkg@1.1"); assert.equal(nsDataSet.authors.get("John Doe").packages.size, 1, "should have 1 author: John Doe"); - nsDataSet.computeAuthor({ name: "John Doe" }); + nsDataSet.computeAuthor({ name: "John Doe" }, "pkg@1.2"); assert.equal(nsDataSet.authors.size, 1, "should have 1 author: John Doe (after the 2nd contribution"); assert.equal(nsDataSet.authors.get("John Doe").packages.size, 2, "should have 1 author: John Doe (2nd time)");