|
1 | 1 | import path from 'path';
|
2 |
| -import {git} from '@commitlint/test'; |
| 2 | +import {fix, git} from '@commitlint/test'; |
3 | 3 | import test from 'ava';
|
4 | 4 | import execa from 'execa';
|
5 | 5 | import {merge} from 'lodash';
|
@@ -118,6 +118,38 @@ test('should pick up parser preset and succeed accordingly', async t => {
|
118 | 118 | t.is(actual.code, 0);
|
119 | 119 | });
|
120 | 120 |
|
| 121 | +test('should pick up config from outside git repo and fail accordingly', async t => { |
| 122 | + const outer = await fix.bootstrap('fixtures/outer-scope'); |
| 123 | + const cwd = await git.init(path.join(outer, 'inner-scope')); |
| 124 | + |
| 125 | + const actual = await cli([], {cwd})('inner: bar'); |
| 126 | + t.is(actual.code, 1); |
| 127 | +}); |
| 128 | + |
| 129 | +test('should pick up config from outside git repo and succeed accordingly', async t => { |
| 130 | + const outer = await fix.bootstrap('fixtures/outer-scope'); |
| 131 | + const cwd = await git.init(path.join(outer, 'inner-scope')); |
| 132 | + |
| 133 | + const actual = await cli([], {cwd})('outer: bar'); |
| 134 | + t.is(actual.code, 0); |
| 135 | +}); |
| 136 | + |
| 137 | +test('should pick up config from inside git repo with precedence and succeed accordingly', async t => { |
| 138 | + const outer = await fix.bootstrap('fixtures/inner-scope'); |
| 139 | + const cwd = await git.init(path.join(outer, 'inner-scope')); |
| 140 | + |
| 141 | + const actual = await cli([], {cwd})('inner: bar'); |
| 142 | + t.is(actual.code, 0); |
| 143 | +}); |
| 144 | + |
| 145 | +test('should pick up config from inside git repo with precedence and fail accordingly', async t => { |
| 146 | + const outer = await fix.bootstrap('fixtures/inner-scope'); |
| 147 | + const cwd = await git.init(path.join(outer, 'inner-scope')); |
| 148 | + |
| 149 | + const actual = await cli([], {cwd})('outer: bar'); |
| 150 | + t.is(actual.code, 1); |
| 151 | +}); |
| 152 | + |
121 | 153 | async function writePkg(payload, options) {
|
122 | 154 | const pkgPath = path.join(options.cwd, 'package.json');
|
123 | 155 | const pkg = JSON.parse(await sander.readFile(pkgPath));
|
|
0 commit comments