@@ -5,6 +5,10 @@ import resolveFrom from 'resolve-from';
5
5
6
6
import load from '.' ;
7
7
8
+ const proxyquire = require ( 'proxyquire' )
9
+ . noCallThru ( )
10
+ . noPreserveCache ( ) ;
11
+
8
12
test ( 'extends-empty should have no rules' , async t => {
9
13
const cwd = await git . bootstrap ( 'fixtures/extends-empty' ) ;
10
14
const actual = await load ( { } , { cwd} ) ;
@@ -24,6 +28,41 @@ test('rules should be loaded from specify config file', async t => {
24
28
t . is ( actual . rules . foo , 'bar' ) ;
25
29
} ) ;
26
30
31
+ test ( 'plugins should be loaded from seed' , async t => {
32
+ const plugin = { '@global' : true } ;
33
+ const scopedPlugin = { '@global' : true } ;
34
+ const stubbedLoad = proxyquire ( '.' , {
35
+ 'commitlint-plugin-example' : plugin ,
36
+ '@scope/commitlint-plugin-example' : scopedPlugin
37
+ } ) ;
38
+
39
+ const cwd = await git . bootstrap ( 'fixtures/extends-empty' ) ;
40
+ const actual = await stubbedLoad (
41
+ { plugins : [ 'example' , '@scope/example' ] } ,
42
+ { cwd}
43
+ ) ;
44
+ t . deepEqual ( actual . plugins , {
45
+ example : plugin ,
46
+ '@scope/example' : scopedPlugin
47
+ } ) ;
48
+ } ) ;
49
+
50
+ test ( 'plugins should be loaded from config' , async t => {
51
+ const plugin = { '@global' : true } ;
52
+ const scopedPlugin = { '@global' : true } ;
53
+ const stubbedLoad = proxyquire ( '.' , {
54
+ 'commitlint-plugin-example' : plugin ,
55
+ '@scope/commitlint-plugin-example' : scopedPlugin
56
+ } ) ;
57
+
58
+ const cwd = await git . bootstrap ( 'fixtures/extends-plugins' ) ;
59
+ const actual = await stubbedLoad ( { } , { cwd} ) ;
60
+ t . deepEqual ( actual . plugins , {
61
+ example : plugin ,
62
+ '@scope/example' : scopedPlugin
63
+ } ) ;
64
+ } ) ;
65
+
27
66
test ( 'uses seed with parserPreset' , async t => {
28
67
const cwd = await git . bootstrap ( 'fixtures/parser-preset' ) ;
29
68
const { parserPreset : actual } = await load (
@@ -61,6 +100,7 @@ test('respects cwd option', async t => {
61
100
t . deepEqual ( actual , {
62
101
formatter : '@commitlint/format' ,
63
102
extends : [ './second-extended' ] ,
103
+ plugins : { } ,
64
104
rules : {
65
105
one : 1 ,
66
106
two : 2
@@ -74,6 +114,7 @@ test('recursive extends', async t => {
74
114
t . deepEqual ( actual , {
75
115
formatter : '@commitlint/format' ,
76
116
extends : [ './first-extended' ] ,
117
+ plugins : { } ,
77
118
rules : {
78
119
zero : 0 ,
79
120
one : 1 ,
@@ -89,6 +130,7 @@ test('recursive extends with json file', async t => {
89
130
t . deepEqual ( actual , {
90
131
formatter : '@commitlint/format' ,
91
132
extends : [ './first-extended' ] ,
133
+ plugins : { } ,
92
134
rules : {
93
135
zero : 0 ,
94
136
one : 1 ,
@@ -104,6 +146,7 @@ test('recursive extends with yaml file', async t => {
104
146
t . deepEqual ( actual , {
105
147
formatter : '@commitlint/format' ,
106
148
extends : [ './first-extended' ] ,
149
+ plugins : { } ,
107
150
rules : {
108
151
zero : 0 ,
109
152
one : 1 ,
@@ -119,6 +162,7 @@ test('recursive extends with js file', async t => {
119
162
t . deepEqual ( actual , {
120
163
formatter : '@commitlint/format' ,
121
164
extends : [ './first-extended' ] ,
165
+ plugins : { } ,
122
166
rules : {
123
167
zero : 0 ,
124
168
one : 1 ,
@@ -134,6 +178,7 @@ test('recursive extends with package.json file', async t => {
134
178
t . deepEqual ( actual , {
135
179
formatter : '@commitlint/format' ,
136
180
extends : [ './first-extended' ] ,
181
+ plugins : { } ,
137
182
rules : {
138
183
zero : 0 ,
139
184
one : 1 ,
@@ -169,6 +214,7 @@ test('ignores unknow keys', async t => {
169
214
t . deepEqual ( actual , {
170
215
formatter : '@commitlint/format' ,
171
216
extends : [ ] ,
217
+ plugins : { } ,
172
218
rules : {
173
219
foo : 'bar' ,
174
220
baz : 'bar'
@@ -183,6 +229,7 @@ test('ignores unknow keys recursively', async t => {
183
229
t . deepEqual ( actual , {
184
230
formatter : '@commitlint/format' ,
185
231
extends : [ './one' ] ,
232
+ plugins : { } ,
186
233
rules : {
187
234
zero : 0 ,
188
235
one : 1
@@ -200,6 +247,7 @@ test('find up from given cwd', async t => {
200
247
t . deepEqual ( actual , {
201
248
formatter : '@commitlint/format' ,
202
249
extends : [ ] ,
250
+ plugins : { } ,
203
251
rules : {
204
252
child : true ,
205
253
inner : false ,
@@ -216,6 +264,7 @@ test('find up config from outside current git repo', async t => {
216
264
t . deepEqual ( actual , {
217
265
formatter : '@commitlint/format' ,
218
266
extends : [ ] ,
267
+ plugins : { } ,
219
268
rules : {
220
269
child : false ,
221
270
inner : false ,
@@ -231,6 +280,7 @@ test('respects formatter option', async t => {
231
280
t . deepEqual ( actual , {
232
281
formatter : 'commitlint-junit' ,
233
282
extends : [ ] ,
283
+ plugins : { } ,
234
284
rules : { }
235
285
} ) ;
236
286
} ) ;
@@ -242,6 +292,7 @@ test('resolves formatter relative from config directory', async t => {
242
292
t . deepEqual ( actual , {
243
293
formatter : resolveFrom ( cwd , './formatters/custom.js' ) ,
244
294
extends : [ ] ,
295
+ plugins : { } ,
245
296
rules : { }
246
297
} ) ;
247
298
} ) ;
@@ -253,6 +304,7 @@ test('returns formatter name when unable to resolve from config directory', asyn
253
304
t . deepEqual ( actual , {
254
305
formatter : './doesnt/exists.js' ,
255
306
extends : [ ] ,
307
+ plugins : { } ,
256
308
rules : { }
257
309
} ) ;
258
310
} ) ;
0 commit comments