From 64edee9d0aa627a8389bbed4a818677e6c8f2c71 Mon Sep 17 00:00:00 2001 From: Mickael Jeanroy Date: Sun, 16 Oct 2022 13:33:59 +0200 Subject: [PATCH] tests: add missing test --- test/fixtures/fake-package-9/index.js | 25 +++++++++++++++++++ test/fixtures/fake-package-9/license/index.md | 1 + test/fixtures/fake-package-9/package.json | 15 +++++++++++ test/license-plugin.spec.js | 13 ++++++++++ 4 files changed, 54 insertions(+) create mode 100644 test/fixtures/fake-package-9/index.js create mode 100644 test/fixtures/fake-package-9/license/index.md create mode 100644 test/fixtures/fake-package-9/package.json diff --git a/test/fixtures/fake-package-9/index.js b/test/fixtures/fake-package-9/index.js new file mode 100644 index 00000000..05935b38 --- /dev/null +++ b/test/fixtures/fake-package-9/index.js @@ -0,0 +1,25 @@ +/** + * The MIT License (MIT) + * + * Copyright (c) 2016-2020 Mickael Jeanroy + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +console.log('fake-package'); diff --git a/test/fixtures/fake-package-9/license/index.md b/test/fixtures/fake-package-9/license/index.md new file mode 100644 index 00000000..65e81201 --- /dev/null +++ b/test/fixtures/fake-package-9/license/index.md @@ -0,0 +1 @@ +license.md file \ No newline at end of file diff --git a/test/fixtures/fake-package-9/package.json b/test/fixtures/fake-package-9/package.json new file mode 100644 index 00000000..9e08f39b --- /dev/null +++ b/test/fixtures/fake-package-9/package.json @@ -0,0 +1,15 @@ +{ + "name": "fake-package", + "version": "1.0.0", + "description": "Fake package used in unit tests", + "main": "src/index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "Mickael Jeanroy ", + "license": "MIT", + "private": true, + "dependencies": { + "lodash": "*" + } +} diff --git a/test/license-plugin.spec.js b/test/license-plugin.spec.js index 97ac8304..1807786f 100644 --- a/test/license-plugin.spec.js +++ b/test/license-plugin.spec.js @@ -191,6 +191,19 @@ describe('LicensePlugin', () => { }); }); + it('should load pkg and do not fail with license directory', () => { + const id = path.join(__dirname, 'fixtures', 'fake-package-9', 'src', 'index.js'); + + plugin.scanDependency(id); + + expect(addDependency).toHaveBeenCalled(); + expect(plugin._dependencies).toEqual({ + 'fake-package': Object.assign(fakePackage, { + licenseText: null, + }), + }); + }); + it('should load pkg including license text from license.md file ignoring case of license file', () => { const id = path.join(__dirname, 'fixtures', 'fake-package-8', 'src', 'index.js');