diff --git a/lib/index.test.js b/lib/index.test.js index 0514606..eda2edb 100644 --- a/lib/index.test.js +++ b/lib/index.test.js @@ -33,7 +33,7 @@ describe('lib/index', () => { test('should upgrade upto patch versions when versions prefixed with ~', async () => { const dir = 'dir1'; - mockJoin.mockImplementation(() => './test_helpers/test1.js'); + mockJoin.mockImplementation(() => '../test-helpers/test1.js'); mockExecAsync .mockImplementationOnce(() => Promise.resolve({ stdout: JSON.stringify(['46.45.45', '46.46.0']) }) @@ -44,7 +44,6 @@ describe('lib/index', () => { await expect(verifyDeps({ dir, logger })).rejects.toThrow( 'Please update your installed modules' ); - console.warn(logger.info.mock.calls); expect(logger.info).toHaveBeenCalledTimes(4); expect(logger.info).toHaveBeenNthCalledWith(1, 'Verifying dependencies…\n'); expect(logger.info).toHaveBeenNthCalledWith(2, 'foo1 is outdated: 46.45.44 → 46.45.45'); @@ -55,7 +54,7 @@ describe('lib/index', () => { test('should upgrade upto minor versions when versions prefixed with ^', async () => { const dir = 'dir2'; - mockJoin.mockImplementation(() => './test_helpers/test2.js'); + mockJoin.mockImplementation(() => '../test-helpers/test2.js'); mockExecAsync .mockImplementationOnce(() => @@ -77,7 +76,7 @@ describe('lib/index', () => { test('should not upgrade locked versions', async () => { const dir = 'dir3'; - mockJoin.mockImplementation(() => './test_helpers/test3.js'); + mockJoin.mockImplementation(() => '../test-helpers/test3.js'); await expect(verifyDeps({ dir, logger })).resolves.toBeUndefined(); expect(logger.info).toHaveBeenCalledTimes(2); @@ -87,7 +86,7 @@ describe('lib/index', () => { test('should compare installed dependencies to latest NPM versions', async () => { const dir = 'dir4'; - mockJoin.mockImplementation(() => './test_helpers/test4.js'); + mockJoin.mockImplementation(() => '../test-helpers/test4.js'); mockExecAsync .mockImplementationOnce(() => Promise.resolve({ stdout: JSON.stringify(['1.0.0', '1.0.1']) })) @@ -104,7 +103,7 @@ describe('lib/index', () => { test('should compare installed devDpendencies to latest NPM versions', async () => { const dir = 'dir5'; - mockJoin.mockImplementation(() => './test_helpers/test5.js'); + mockJoin.mockImplementation(() => '../test-helpers/test5.js'); mockExecAsync .mockImplementationOnce(() => Promise.resolve({ stdout: JSON.stringify(['1.0.0', '1.0.1']) })) @@ -121,8 +120,8 @@ describe('lib/index', () => { test('should show dependency update required when using semver and later version in range is available', async () => { const dir = 'dir6'; mockJoin - .mockImplementationOnce(() => './test_helpers/test6.js') - .mockImplementationOnce(() => './test_helpers/test6.js') + .mockImplementationOnce(() => '../test-helpers/test6.js') + .mockImplementationOnce(() => '../test-helpers/test6.js') .mockImplementationOnce(() => { throw new Error('foo'); }); @@ -153,7 +152,7 @@ describe('lib/index', () => { test('should not show dependency update required when using semver and later version is out of range', async () => { const dir = 'dir7'; - mockJoin.mockImplementation(() => './test_helpers/test7.js'); + mockJoin.mockImplementation(() => '../test-helpers/test7.js'); mockExecAsync .mockImplementationOnce(() => Promise.resolve({ stdout: JSON.stringify(['1.0.0', '2.0.0']) })) .mockImplementationOnce(() => @@ -167,7 +166,7 @@ describe('lib/index', () => { test('should show dependency update required when version is locked if non-major-version update available', async () => { const dir = 'dir8'; - mockJoin.mockImplementation(() => './test_helpers/test8.js'); + mockJoin.mockImplementation(() => '../test-helpers/test8.js'); mockExecAsync .mockImplementationOnce(() => Promise.resolve({ stdout: JSON.stringify(['1.0.0']) })) .mockImplementationOnce(() => Promise.resolve({ stdout: JSON.stringify(['1.0.0', '1.1.0']) })) @@ -201,7 +200,7 @@ describe('lib/index', () => { test('should not show dependency update required when version is locked if major-version update available', async () => { const dir = 'dir9'; - mockJoin.mockImplementation(() => './test_helpers/test9.js'); + mockJoin.mockImplementation(() => '../test-helpers/test9.js'); mockExecAsync .mockImplementationOnce(() => Promise.resolve({ stdout: JSON.stringify(['1.0.0', '2.0.0']) })) @@ -220,7 +219,7 @@ describe('lib/index', () => { test('should show dependency install required if module cannot be found', async () => { const dir = 'dir10'; - mockJoin.mockImplementation(() => './test_helpers/test10.js'); + mockJoin.mockImplementation(() => '../test-helpers/test10.js'); mockExecAsync .mockImplementationOnce(() => Promise.resolve({ stdout: JSON.stringify(['1.0.0', '1.0.1']) })) .mockImplementationOnce(() => Promise.resolve({ stdout: JSON.stringify(['1.0.0', '1.0.1']) })) @@ -233,7 +232,6 @@ describe('lib/index', () => { await expect(verifyDeps({ dir, logger })).rejects.toThrow( 'Please update your installed modules.' ); - console.warn(logger.info.mock.calls); expect(logger.info).toHaveBeenCalledTimes(5); expect(logger.info).toHaveBeenNthCalledWith(1, 'Verifying dependencies…\n'); expect(logger.info).toHaveBeenNthCalledWith(2, `eri is not installed`); @@ -244,7 +242,7 @@ describe('lib/index', () => { test('should show dependency install required if fetching versions does not return valid JSON output', async () => { const dir = 'dir11'; - mockJoin.mockImplementation(() => './test_helpers/test11.js'); + mockJoin.mockImplementation(() => '../test-helpers/test11.js'); const invalidOutput = 'boo'; mockExecAsync.mockImplementationOnce(() => ({ stdout: invalidOutput })); let syntaxError; @@ -260,7 +258,7 @@ describe('lib/index', () => { test('should show dependency install required if fetching tags does not return valid JSON output', async () => { const dir = 'dir12'; - mockJoin.mockImplementation(() => './test_helpers/test12.js'); + mockJoin.mockImplementation(() => '../test-helpers/test12.js'); const invalidOutput = 'boo'; mockExecAsync .mockImplementationOnce(() => @@ -280,7 +278,7 @@ describe('lib/index', () => { test('throw error when getting latest versions fails', async () => { const dir = 'dir13'; - mockJoin.mockImplementation(() => './test_helpers/test13.js'); + mockJoin.mockImplementation(() => '../test-helpers/test13.js'); mockExecAsync.mockImplementation(() => { throw new Error('foo'); }); @@ -291,7 +289,7 @@ describe('lib/index', () => { test('throw error when getting latest tag fails', async () => { const dir = 'dir14'; - mockJoin.mockImplementation(() => './test_helpers/test14.js'); + mockJoin.mockImplementation(() => '../test-helpers/test14.js'); mockExecAsync .mockImplementationOnce(() => Promise.resolve({ stdout: JSON.stringify({ stdout: JSON.stringify(['1.0.0', '1.0.1']) }) }) @@ -306,7 +304,7 @@ describe('lib/index', () => { test('should show dependency install required if latest module is installed but not reflected in package.json', async () => { const dir = 'dir15'; - mockJoin.mockImplementation(() => './test_helpers/test15.js'); + mockJoin.mockImplementation(() => '../test-helpers/test15.js'); mockExecAsync .mockImplementationOnce(() => Promise.resolve({ stdout: JSON.stringify(['1.0.0', '1.0.1']) })) .mockImplementationOnce(() => Promise.resolve({ stdout: JSON.stringify(['1.0.0', '1.0.1']) })) @@ -329,7 +327,7 @@ describe('lib/index', () => { test('should not throw an error if no dependencies are in package.json', async () => { const dir = 'dir16'; - mockJoin.mockImplementation(() => './test_helpers/test16.js'); + mockJoin.mockImplementation(() => '../test-helpers/test16.js'); await verifyDeps({ dir, logger }); expect(logger.info).toHaveBeenCalledTimes(2); expect(logger.info).toHaveBeenNthCalledWith(1, 'Verifying dependencies…\n'); @@ -340,7 +338,7 @@ describe('lib/index', () => { const consoleInfo = console.info; console.info = jest.fn(); const dir = 'dir17'; - mockJoin.mockImplementation(() => './test_helpers/test17.js'); + mockJoin.mockImplementation(() => '../test-helpers/test17.js'); mockExecAsync .mockImplementationOnce(() => Promise.resolve({ stdout: JSON.stringify(['1.0.0', '1.0.1']) })) .mockImplementationOnce(() => Promise.resolve({ stdout: JSON.stringify(['1.0.0', '1.0.1']) })) @@ -361,7 +359,7 @@ describe('lib/index', () => { }); test('should not throw type error if options are not passed', async () => { - mockJoin.mockImplementation(() => './test_helpers/test18.js'); + mockJoin.mockImplementation(() => '../test-helpers/test18.js'); mockExecAsync .mockImplementationOnce(() => Promise.resolve({ stdout: JSON.stringify(['1.0.0', '1.0.1']) })) .mockImplementationOnce(() => @@ -375,7 +373,7 @@ describe('lib/index', () => { test('should update to version aliased as latest when aliased latest is less that most recent published version', async () => { const dir = 'dir19'; - mockJoin.mockImplementation(() => './test_helpers/test19.js'); + mockJoin.mockImplementation(() => '../test-helpers/test19.js'); mockExecAsync .mockImplementationOnce(() => Promise.resolve({ stdout: JSON.stringify(['1.2.4', '1.2.5']) })) .mockImplementationOnce(() => Promise.resolve({ stdout: JSON.stringify(['1.2.4', '1.2.5']) })) @@ -403,7 +401,7 @@ describe('lib/index', () => { test('should upgrade pre-release versions to latest pre-release version available', async () => { const dir = 'dir20'; - mockJoin.mockImplementation(() => './test_helpers/test20.js'); + mockJoin.mockImplementation(() => '../test-helpers/test20.js'); mockExecAsync .mockImplementationOnce(() => Promise.resolve({ stdout: JSON.stringify(['1.0.0-alpha.1', '1.0.0-alpha.2', '1.2.4']) }) @@ -426,7 +424,7 @@ describe('lib/index', () => { test('should not upgrade when no version available for major version of pre-release', async () => { const dir = 'dir21'; - mockJoin.mockImplementation(() => './test_helpers/test21.js'); + mockJoin.mockImplementation(() => '../test-helpers/test21.js'); mockExecAsync .mockImplementationOnce(() => { return Promise.resolve({ @@ -450,7 +448,7 @@ describe('lib/index', () => { test('should throw an error when version in package.json is invalid (likely unpublished)', async () => { const dir = 'dir22'; - mockJoin.mockImplementation(() => './test_helpers/test22.js'); + mockJoin.mockImplementation(() => '../test-helpers/test22.js'); mockExecAsync .mockImplementationOnce(() => Promise.resolve({ stdout: JSON.stringify(['1.0.0', '1.2.1']) })) .mockImplementationOnce(() => @@ -464,7 +462,7 @@ describe('lib/index', () => { test('autoUpgrade modules', async () => { const dir = 'dir23'; - mockJoin.mockImplementation(() => './test_helpers/test23.js'); + mockJoin.mockImplementation(() => '../test-helpers/test23.js'); mockExecAsync .mockImplementationOnce(() => Promise.resolve({ stdout: JSON.stringify(['1.0.0', '1.0.1']) })) .mockImplementationOnce(() => Promise.resolve({ stdout: JSON.stringify(['1.0.0', '1.0.1']) })) @@ -492,7 +490,7 @@ describe('lib/index', () => { test('throw error when npm module name is invalid', async () => { const dir = 'dir24'; - mockJoin.mockImplementation(() => './test_helpers/test24.js'); + mockJoin.mockImplementation(() => '../test-helpers/test24.js'); await expect(verifyDeps({ autoUpgrade: true, dir, logger })).rejects.toThrow( 'NPM package name: "bad name Dependency" is invalid. name can only contain URL-friendly characters' ); @@ -500,7 +498,7 @@ describe('lib/index', () => { test('should verify dependencies when npm module has one version available, npm view returns string instead of array', async () => { const dir = 'dir25'; - mockJoin.mockImplementation(() => './test_helpers/test25.js'); + mockJoin.mockImplementation(() => '../test-helpers/test25.js'); mockExecAsync .mockImplementationOnce(() => Promise.resolve({ stdout: '"1.1.1"' })) .mockImplementationOnce(() => diff --git a/lib/test_helpers/test1.js b/test-helpers/test1.js similarity index 100% rename from lib/test_helpers/test1.js rename to test-helpers/test1.js diff --git a/lib/test_helpers/test10.js b/test-helpers/test10.js similarity index 100% rename from lib/test_helpers/test10.js rename to test-helpers/test10.js diff --git a/lib/test_helpers/test11.js b/test-helpers/test11.js similarity index 100% rename from lib/test_helpers/test11.js rename to test-helpers/test11.js diff --git a/lib/test_helpers/test12.js b/test-helpers/test12.js similarity index 100% rename from lib/test_helpers/test12.js rename to test-helpers/test12.js diff --git a/lib/test_helpers/test13.js b/test-helpers/test13.js similarity index 100% rename from lib/test_helpers/test13.js rename to test-helpers/test13.js diff --git a/lib/test_helpers/test14.js b/test-helpers/test14.js similarity index 100% rename from lib/test_helpers/test14.js rename to test-helpers/test14.js diff --git a/lib/test_helpers/test15.js b/test-helpers/test15.js similarity index 100% rename from lib/test_helpers/test15.js rename to test-helpers/test15.js diff --git a/lib/test_helpers/test16.js b/test-helpers/test16.js similarity index 100% rename from lib/test_helpers/test16.js rename to test-helpers/test16.js diff --git a/lib/test_helpers/test17.js b/test-helpers/test17.js similarity index 100% rename from lib/test_helpers/test17.js rename to test-helpers/test17.js diff --git a/lib/test_helpers/test18.js b/test-helpers/test18.js similarity index 100% rename from lib/test_helpers/test18.js rename to test-helpers/test18.js diff --git a/lib/test_helpers/test19.js b/test-helpers/test19.js similarity index 100% rename from lib/test_helpers/test19.js rename to test-helpers/test19.js diff --git a/lib/test_helpers/test2.js b/test-helpers/test2.js similarity index 100% rename from lib/test_helpers/test2.js rename to test-helpers/test2.js diff --git a/lib/test_helpers/test20.js b/test-helpers/test20.js similarity index 100% rename from lib/test_helpers/test20.js rename to test-helpers/test20.js diff --git a/lib/test_helpers/test21.js b/test-helpers/test21.js similarity index 100% rename from lib/test_helpers/test21.js rename to test-helpers/test21.js diff --git a/lib/test_helpers/test22.js b/test-helpers/test22.js similarity index 100% rename from lib/test_helpers/test22.js rename to test-helpers/test22.js diff --git a/lib/test_helpers/test23.js b/test-helpers/test23.js similarity index 100% rename from lib/test_helpers/test23.js rename to test-helpers/test23.js diff --git a/lib/test_helpers/test24.js b/test-helpers/test24.js similarity index 100% rename from lib/test_helpers/test24.js rename to test-helpers/test24.js diff --git a/lib/test_helpers/test25.js b/test-helpers/test25.js similarity index 100% rename from lib/test_helpers/test25.js rename to test-helpers/test25.js diff --git a/lib/test_helpers/test3.js b/test-helpers/test3.js similarity index 100% rename from lib/test_helpers/test3.js rename to test-helpers/test3.js diff --git a/lib/test_helpers/test4.js b/test-helpers/test4.js similarity index 100% rename from lib/test_helpers/test4.js rename to test-helpers/test4.js diff --git a/lib/test_helpers/test5.js b/test-helpers/test5.js similarity index 100% rename from lib/test_helpers/test5.js rename to test-helpers/test5.js diff --git a/lib/test_helpers/test6.js b/test-helpers/test6.js similarity index 100% rename from lib/test_helpers/test6.js rename to test-helpers/test6.js diff --git a/lib/test_helpers/test7.js b/test-helpers/test7.js similarity index 100% rename from lib/test_helpers/test7.js rename to test-helpers/test7.js diff --git a/lib/test_helpers/test8.js b/test-helpers/test8.js similarity index 100% rename from lib/test_helpers/test8.js rename to test-helpers/test8.js diff --git a/lib/test_helpers/test9.js b/test-helpers/test9.js similarity index 100% rename from lib/test_helpers/test9.js rename to test-helpers/test9.js