|
1 | 1 | import path from 'path';
|
2 |
| -import {fix, git} from '@commitlint/test'; |
| 2 | +import {fix, git, npm} from '@commitlint/test'; |
3 | 3 | import test from 'ava';
|
| 4 | +import execa from 'execa'; |
4 | 5 | import resolveFrom from 'resolve-from';
|
5 | 6 |
|
6 | 7 | import load from '.';
|
@@ -327,3 +328,43 @@ test('does not mutate config module reference', async t => {
|
327 | 328 |
|
328 | 329 | t.is(before, after);
|
329 | 330 | });
|
| 331 | + |
| 332 | +test('resolves parser preset from conventional commits', async t => { |
| 333 | + const cwd = await npm.bootstrap('fixtures/parser-preset-conventionalcommits'); |
| 334 | + const actual = await load({}, {cwd}); |
| 335 | + |
| 336 | + t.is(actual.parserPreset.name, 'conventional-changelog-conventionalcommits'); |
| 337 | + t.is(typeof actual.parserPreset.parserOpts, 'object'); |
| 338 | + t.deepEqual( |
| 339 | + actual.parserPreset.parserOpts.headerPattern, |
| 340 | + /^(\w*)(?:\((.*)\))?!?: (.*)$/ |
| 341 | + ); |
| 342 | +}); |
| 343 | + |
| 344 | +test('resolves parser preset from conventional angular', async t => { |
| 345 | + const cwd = await npm.bootstrap('fixtures/parser-preset-angular'); |
| 346 | + const actual = await load({}, {cwd}); |
| 347 | + |
| 348 | + t.is(actual.parserPreset.name, 'conventional-changelog-angular'); |
| 349 | + t.is(typeof actual.parserPreset.parserOpts, 'object'); |
| 350 | + t.deepEqual( |
| 351 | + actual.parserPreset.parserOpts.headerPattern, |
| 352 | + /^(\w*)(?:\((.*)\))?: (.*)$/ |
| 353 | + ); |
| 354 | +}); |
| 355 | + |
| 356 | +test('recursive resolves parser preset from conventional atom', async t => { |
| 357 | + const cwd = await git.bootstrap( |
| 358 | + 'fixtures/recursive-parser-preset-conventional-atom' |
| 359 | + ); |
| 360 | + // the package file is nested in 2 folders, `npm.bootstrap` cant do that |
| 361 | + await execa('npm', ['install'], { |
| 362 | + cwd: path.resolve(cwd, 'first-extended', 'second-extended') |
| 363 | + }); |
| 364 | + |
| 365 | + const actual = await load({}, {cwd}); |
| 366 | + |
| 367 | + t.is(actual.parserPreset.name, 'conventional-changelog-atom'); |
| 368 | + t.is(typeof actual.parserPreset.parserOpts, 'object'); |
| 369 | + t.deepEqual(actual.parserPreset.parserOpts.headerPattern, /^(:.*?:) (.*)$/); |
| 370 | +}); |
0 commit comments