Skip to content

Commit 6e4dabc

Browse files
committed
Add new tests for npm package.json file
Signed-off-by: Divyansh2512 <[email protected]>
1 parent 71c7cef commit 6e4dabc

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tests/packagedcode/test_npm.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,19 @@ def test_parse_npm_shrinkwrap(self):
245245
packages = npm.parse(test_file)
246246
self.check_packages(packages, expected_loc, regen=False)
247247

248+
def test_parse_with_name(self):
249+
test_file = self.get_test_loc('npm/with_name/package.json')
250+
expected_loc = self.get_test_loc('npm/with_name/package.json.expected')
251+
packages = npm.parse(test_file)
252+
self.check_packages(packages, expected_loc, regen=False)
253+
254+
def test_parse_without_name(self):
255+
test_file = self.get_test_loc('npm/without_name/package.json')
256+
try:
257+
npm.parse(test_file)
258+
except AttributeError as e:
259+
assert "'NoneType' object has no attribute 'to_dict'" in str(e)
260+
248261
def test_parse_yarn_lock(self):
249262
test_file = self.get_test_loc('npm/yarn-lock/yarn.lock')
250263
expected_loc = self.get_test_loc(

0 commit comments

Comments
 (0)