1
- import getConfig from '../../lib/getConfig ' ;
1
+ import Config from '../../lib/Config ' ;
2
2
import commitMeetsRules from '../../lib/helpers/commitMeetsRules' ;
3
3
4
- jest . mock ( '../../lib/getConfig' , jest . fn ) ;
5
-
6
- const getConfigMock = getConfig as jest . MockedFunction < typeof getConfig > ;
7
-
8
4
describe ( 'commitMeetsRules' , ( ) => {
9
5
it ( 'should have one of the types' , ( ) => {
10
- getConfigMock . mockReturnValue ( {
6
+ jest . spyOn ( Config . prototype , 'config' , 'get' ) . mockReturnValue ( {
11
7
types : [
12
8
{ type : 'Chore' } ,
13
9
] ,
@@ -18,8 +14,8 @@ describe('commitMeetsRules', () => {
18
14
expect ( commitMeetsRules ( 'Chore : true' ) ) . toBe ( false ) ;
19
15
} ) ;
20
16
21
- it ( 'should have one of the types' , ( ) => {
22
- getConfigMock . mockReturnValue ( {
17
+ it ( 'should have one of the types 2 ' , ( ) => {
18
+ jest . spyOn ( Config . prototype , 'config' , 'get' ) . mockReturnValue ( {
23
19
lowercaseTypes : true ,
24
20
types : [
25
21
{ type : 'Chore' } ,
@@ -34,7 +30,7 @@ describe('commitMeetsRules', () => {
34
30
} ) ;
35
31
36
32
it ( 'should have one of the types with different delimiter' , ( ) => {
37
- getConfigMock . mockReturnValue ( {
33
+ jest . spyOn ( Config . prototype , 'config' , 'get' ) . mockReturnValue ( {
38
34
delimiter : ' -' ,
39
35
types : [
40
36
{ type : 'Chore' } ,
@@ -49,7 +45,7 @@ describe('commitMeetsRules', () => {
49
45
} ) ;
50
46
51
47
it ( 'should not have scope' , ( ) => {
52
- getConfigMock . mockReturnValue ( {
48
+ jest . spyOn ( Config . prototype , 'config' , 'get' ) . mockReturnValue ( {
53
49
scope : false ,
54
50
types : [
55
51
{ type : 'Feat' } ,
@@ -67,7 +63,7 @@ describe('commitMeetsRules', () => {
67
63
} ) ;
68
64
69
65
it ( 'should have optional scope' , ( ) => {
70
- getConfigMock . mockReturnValue ( {
66
+ jest . spyOn ( Config . prototype , 'config' , 'get' ) . mockReturnValue ( {
71
67
scope : true ,
72
68
types : [
73
69
{ type : 'Feat' } ,
@@ -84,7 +80,7 @@ describe('commitMeetsRules', () => {
84
80
} ) ;
85
81
86
82
it ( 'should have optional scope with scopespace' , ( ) => {
87
- getConfigMock . mockReturnValue ( {
83
+ jest . spyOn ( Config . prototype , 'config' , 'get' ) . mockReturnValue ( {
88
84
scope : true ,
89
85
addScopeSpace : true ,
90
86
types : [
@@ -102,7 +98,7 @@ describe('commitMeetsRules', () => {
102
98
} ) ;
103
99
104
100
it ( 'should have dot ending' , ( ) => {
105
- getConfigMock . mockReturnValue ( {
101
+ jest . spyOn ( Config . prototype , 'config' , 'get' ) . mockReturnValue ( {
106
102
rules : {
107
103
endWithDot : true ,
108
104
} ,
@@ -118,7 +114,7 @@ describe('commitMeetsRules', () => {
118
114
} ) ;
119
115
120
116
it ( 'should have no dot ending' , ( ) => {
121
- getConfigMock . mockReturnValue ( {
117
+ jest . spyOn ( Config . prototype , 'config' , 'get' ) . mockReturnValue ( {
122
118
rules : {
123
119
endWithDot : false ,
124
120
} ,
@@ -134,7 +130,7 @@ describe('commitMeetsRules', () => {
134
130
} ) ;
135
131
136
132
it ( 'should have correct length' , ( ) => {
137
- getConfigMock . mockReturnValue ( {
133
+ jest . spyOn ( Config . prototype , 'config' , 'get' ) . mockReturnValue ( {
138
134
rules : {
139
135
maxChar : 10 ,
140
136
minChar : 8 ,
@@ -152,7 +148,7 @@ describe('commitMeetsRules', () => {
152
148
} ) ;
153
149
154
150
it ( 'should have no length' , ( ) => {
155
- getConfigMock . mockReturnValue ( {
151
+ jest . spyOn ( Config . prototype , 'config' , 'get' ) . mockReturnValue ( {
156
152
types : [
157
153
{ type : 'Feat' } ,
158
154
] ,
@@ -166,7 +162,7 @@ describe('commitMeetsRules', () => {
166
162
} ) ;
167
163
168
164
it ( 'should have body' , ( ) => {
169
- getConfigMock . mockReturnValue ( {
165
+ jest . spyOn ( Config . prototype , 'config' , 'get' ) . mockReturnValue ( {
170
166
body : true ,
171
167
types : [
172
168
{ type : 'Feat' } ,
@@ -179,7 +175,7 @@ describe('commitMeetsRules', () => {
179
175
} ) ;
180
176
181
177
it ( 'should have initial commit' , ( ) => {
182
- getConfigMock . mockReturnValue ( {
178
+ jest . spyOn ( Config . prototype , 'config' , 'get' ) . mockReturnValue ( {
183
179
initialCommit : {
184
180
isEnabled : true ,
185
181
message : 'initial commit' ,
@@ -189,7 +185,7 @@ describe('commitMeetsRules', () => {
189
185
expect ( commitMeetsRules ( 'initial commit' ) ) . toBe ( true ) ;
190
186
expect ( commitMeetsRules ( 'Initial commit' ) ) . toBe ( false ) ;
191
187
192
- getConfigMock . mockReturnValue ( {
188
+ jest . spyOn ( Config . prototype , 'config' , 'get' ) . mockReturnValue ( {
193
189
initialCommit : {
194
190
isEnabled : false ,
195
191
message : 'initial commit' ,
0 commit comments