diff options
Diffstat (limited to 'spec/integration/js')
| -rw-r--r-- | spec/integration/js/npm_spec.rb | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/spec/integration/js/npm_spec.rb b/spec/integration/js/npm_spec.rb index 69c806b..5084111 100644 --- a/spec/integration/js/npm_spec.rb +++ b/spec/integration/js/npm_spec.rb @@ -3,11 +3,13 @@ require 'spec_helper' RSpec.describe "npm" do + subject { runner.scan(env: env) } + + let(:env) { {} } + include_examples "each report version", "js", "npm", "e80dba9c" context 'when scanning a project with no dependencies' do - subject { runner.scan } - before do runner.add_file('package.json') do JSON.generate(name: "example", version: "1.0.0", license: "ISC") @@ -22,8 +24,6 @@ RSpec.describe "npm" do end context 'when scanning a project with a single dependency and a `package-lock.json` file' do - subject { runner.scan } - before do runner.mount(dir: fixture_file('js/single-declared-dependency')) end @@ -169,8 +169,6 @@ RSpec.describe "npm" do end context 'when scanning a project without a `package-lock.json` file' do - subject { runner.scan } - before do runner.add_file('package.json', fixture_file_content('js/single-declared-dependency/package.json')) end @@ -316,8 +314,6 @@ RSpec.describe "npm" do end context "when scanning a project with an older engine" do - subject { runner.scan } - before do runner.add_file('package.json') do JSON.generate( @@ -470,7 +466,7 @@ RSpec.describe "npm" do end context "when scanning a project with dependencies sourced from a custom registry" do - subject { runner.scan(env: { 'ADDITIONAL_CA_CERT_BUNDLE' => x509_certificate.read }) } + let(:env) { { 'ADDITIONAL_CA_CERT_BUNDLE' => x509_certificate.read } } let(:private_npm_host) { 'npm.test' } @@ -508,4 +504,19 @@ RSpec.describe "npm" do specify { expect(subject.licenses_for('js-npm')).to match_array(['MIT']) } specify { expect(subject.licenses_for('lodash')).to match_array(['MIT']) } end + + context "when scanning project in a sub directory" do + let(:env) do + { + 'LICENSE_FINDER_CLI_OPTS' => '--project-path=service/frontend' + } + end + + before do + runner.mount(dir: fixture_file('js/npm/nested')) + end + + specify { expect(subject).to match_schema } + specify { expect(subject.dependency_names).to include("@angular/animations", "@angular/common", "@angular/compiler", "@angular/core", "@angular/forms") } + end end |
