|
1 | 1 | import {lerna} from '@commitlint/test';
|
2 | 2 | import config from '.';
|
| 3 | +import semver from 'semver'; |
3 | 4 |
|
4 | 5 | test('exports rules key', () => {
|
5 | 6 | expect(config).toHaveProperty('rules');
|
@@ -70,5 +71,27 @@ test('returns expected value for scoped lerna repository', async () => {
|
70 | 71 | test('works with lerna version < 3', async () => {
|
71 | 72 | const {'scope-enum': fn} = config.rules;
|
72 | 73 | const cwd = await lerna.bootstrap('lerna-two', __dirname);
|
73 |
| - await expect(fn({cwd})).resolves.toBeTruthy(); |
| 74 | + const [, , value] = await fn({cwd}); |
| 75 | + expect(value).toEqual(['a2', 'b2']); |
| 76 | +}); |
| 77 | + |
| 78 | +test('uses lerna version < 3 if installed', async () => { |
| 79 | + const semverLt = jest.spyOn(semver, 'lt'); |
| 80 | + const cwd = await lerna.bootstrap('lerna-two', __dirname); |
| 81 | + const packages = await config.utils.getPackages({cwd}); |
| 82 | + |
| 83 | + expect(packages).toEqual(['a2', 'b2']); |
| 84 | + expect(semverLt).toHaveBeenLastCalledWith('2.11.0', '3.0.0'); |
| 85 | + expect(semverLt).toHaveLastReturnedWith(true); |
| 86 | +}); |
| 87 | + |
| 88 | +test('uses lerna version >= 3 if installed', async () => { |
| 89 | + const semverLt = jest.spyOn(semver, 'lt'); |
| 90 | + const cwd = await lerna.bootstrap('basic', __dirname); |
| 91 | + |
| 92 | + const packages = await config.utils.getPackages({cwd}); |
| 93 | + |
| 94 | + expect(packages).toEqual(['a', 'b']); |
| 95 | + expect(semverLt).toHaveBeenLastCalledWith('3.20.2', '3.0.0'); |
| 96 | + expect(semverLt).toHaveLastReturnedWith(false); |
74 | 97 | });
|
0 commit comments