Skip to content

Commit

Permalink
fix: more test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Kit Plummer committed Nov 13, 2022
1 parent 5f857c9 commit 37ca8fd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
8 changes: 4 additions & 4 deletions test/mix_scan_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -67,23 +67,23 @@ defmodule Mix.Tasks.ScanTest do
paths = %{node: ["./test/fixtures/packagejson", "./test/fixtures/package-lockjson"]}
{reports_list, [], deps_count} = Npm.Scanner.scan(true, paths, "")

assert 4 == deps_count
assert 4 == Enum.count(reports_list)
assert 1 == deps_count
assert 1 == Enum.count(reports_list)
end

test "run scan against first-degree dependencies if package-lock does not exist" do
path = %{node: ["./test/fixtures/packagejson"]}
{reports_list, [], deps_count} = Npm.Scanner.scan(true, path, "")

assert 1 == deps_count
assert 2 == Enum.count(reports_list)
assert 1 == Enum.count(reports_list)
end

test "run scan against package.json and yarn.lock" do
paths = %{node: ["./test/fixtures/packagejson", "./test/fixtures/yarnlock"]}
{[], reports_list, deps_count} = Npm.Scanner.scan(true, paths, "")

assert 2 == deps_count
assert 1 == deps_count
assert 1 == Enum.count(reports_list)
end

Expand Down
12 changes: 3 additions & 9 deletions test/npm/package_json_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,21 @@ defmodule PackageJSONTest do
{lib_map, deps_count} = Npm.Packagefile.parse!(File.read!("./test/fixtures/packagejson"))

parsed_package_json = [
{"async", "2.1.4"},
{"benchmark", "2.1.3"},
{"chalk", "1.1.3"},
{"request", "2.88.0"}
{"simple-npm-package", "3.0.8"}
]

assert deps_count == 4
assert deps_count == 1
assert parsed_package_json == lib_map
end

test "extracts dependencies from package-lock.json" do
{lib_map, deps_count} = Npm.Packagefile.parse!(File.read!("./test/fixtures/package-lockjson"))

parsed_package_lock_json = [
{"ajv", "6.10.2"},
{"assert-plus", "1.0.0"},
{"bcrypt-pbkdf", "1.0.2"},
{"combined-stream", "1.0.8"}
]

assert deps_count == 4
assert deps_count == 1
assert parsed_package_lock_json == lib_map
end
end
4 changes: 2 additions & 2 deletions test/npm/yarnlock_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ defmodule YarnlockTest do
test "extracts dependencies from yarn.lock" do
{lib_map, deps_count} = Npm.Yarnlockfile.parse!(File.read!("./test/fixtures/yarnlock"))

parsed_yarn = [{"ajv", "6.12.3"}, {"asn1", "0.2.4"}, {"assert-plus", "1.0.0"}]
parsed_yarn = [{"assert-plus", "1.0.0"}]

assert deps_count == 3
assert deps_count == 1
assert parsed_yarn == lib_map
end
end

0 comments on commit 37ca8fd

Please sign in to comment.