From c004dc3da6fef5098b712c3e9758d5b2a86e6e0a Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Thu, 14 Sep 2017 13:48:34 +0200 Subject: [PATCH] Add test that manifest-less local packages are installable, #4257 --- __tests__/commands/install/integration.js | 11 ++++++++++- .../install/install-file-no-package/bar/bar.js | 0 .../install/install-file-no-package/package.json | 6 ++++++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 __tests__/fixtures/install/install-file-no-package/bar/bar.js create mode 100644 __tests__/fixtures/install/install-file-no-package/package.json diff --git a/__tests__/commands/install/integration.js b/__tests__/commands/install/integration.js index 07278e079a..38643c32ac 100644 --- a/__tests__/commands/install/integration.js +++ b/__tests__/commands/install/integration.js @@ -483,13 +483,22 @@ test.concurrent("don't install with file: protocol as default if target is a fil return expect(runInstall({lockfile: false}, 'install-file-as-default-no-file')).rejects.toBeDefined(); }); -test.concurrent("don't install with file: protocol as default if target does not have package.json", (): Promise< +test.concurrent("don't install with implicit file: protocol if target does not have package.json", (): Promise< void, > => { // $FlowFixMe return expect(runInstall({lockfile: false}, 'install-file-as-default-no-package')).rejects.toBeDefined(); }); +test.concurrent("install with explicit file: protocol if target does not have package.json", (): Promise< + void, +> => { + return runInstall({}, 'install-file-no-package', async config => { + expect(await fs.exists(path.join(config.cwd, 'node_modules', 'foo', 'bar.js'))).toEqual(true); + expect(await fs.exists(path.join(config.cwd, 'node_modules', 'bar', 'bar.js'))).toEqual(true); + }); +}); + test.concurrent("don't install with file: protocol as default if target is valid semver", (): Promise => { return runInstall({}, 'install-file-as-default-no-semver', async config => { expect(await fs.readFile(path.join(config.cwd, 'node_modules', 'foo', 'package.json'))).toMatchSnapshot( diff --git a/__tests__/fixtures/install/install-file-no-package/bar/bar.js b/__tests__/fixtures/install/install-file-no-package/bar/bar.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/__tests__/fixtures/install/install-file-no-package/package.json b/__tests__/fixtures/install/install-file-no-package/package.json new file mode 100644 index 0000000000..80d05da943 --- /dev/null +++ b/__tests__/fixtures/install/install-file-no-package/package.json @@ -0,0 +1,6 @@ +{ + "dependencies": { + "foo": "file:bar", + "bar": "./bar" + } +}