1- import getConfig from '../../lib/getConfig ' ;
1+ import Config from '../../lib/Config ' ;
22import commitMeetsRules from '../../lib/helpers/commitMeetsRules' ;
33
4- jest . mock ( '../../lib/getConfig' , jest . fn ) ;
5-
6- const getConfigMock = getConfig as jest . MockedFunction < typeof getConfig > ;
7-
84describe ( 'commitMeetsRules' , ( ) => {
95 it ( 'should have one of the types' , ( ) => {
10- getConfigMock . mockReturnValue ( {
6+ jest . spyOn ( Config . prototype , 'config' , 'get' ) . mockReturnValue ( {
117 types : [
128 { type : 'Chore' } ,
139 ] ,
@@ -18,8 +14,8 @@ describe('commitMeetsRules', () => {
1814 expect ( commitMeetsRules ( 'Chore : true' ) ) . toBe ( false ) ;
1915 } ) ;
2016
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 ( {
2319 lowercaseTypes : true ,
2420 types : [
2521 { type : 'Chore' } ,
@@ -34,7 +30,7 @@ describe('commitMeetsRules', () => {
3430 } ) ;
3531
3632 it ( 'should have one of the types with different delimiter' , ( ) => {
37- getConfigMock . mockReturnValue ( {
33+ jest . spyOn ( Config . prototype , 'config' , 'get' ) . mockReturnValue ( {
3834 delimiter : ' -' ,
3935 types : [
4036 { type : 'Chore' } ,
@@ -49,7 +45,7 @@ describe('commitMeetsRules', () => {
4945 } ) ;
5046
5147 it ( 'should not have scope' , ( ) => {
52- getConfigMock . mockReturnValue ( {
48+ jest . spyOn ( Config . prototype , 'config' , 'get' ) . mockReturnValue ( {
5349 scope : false ,
5450 types : [
5551 { type : 'Feat' } ,
@@ -67,7 +63,7 @@ describe('commitMeetsRules', () => {
6763 } ) ;
6864
6965 it ( 'should have optional scope' , ( ) => {
70- getConfigMock . mockReturnValue ( {
66+ jest . spyOn ( Config . prototype , 'config' , 'get' ) . mockReturnValue ( {
7167 scope : true ,
7268 types : [
7369 { type : 'Feat' } ,
@@ -84,7 +80,7 @@ describe('commitMeetsRules', () => {
8480 } ) ;
8581
8682 it ( 'should have optional scope with scopespace' , ( ) => {
87- getConfigMock . mockReturnValue ( {
83+ jest . spyOn ( Config . prototype , 'config' , 'get' ) . mockReturnValue ( {
8884 scope : true ,
8985 addScopeSpace : true ,
9086 types : [
@@ -102,7 +98,7 @@ describe('commitMeetsRules', () => {
10298 } ) ;
10399
104100 it ( 'should have dot ending' , ( ) => {
105- getConfigMock . mockReturnValue ( {
101+ jest . spyOn ( Config . prototype , 'config' , 'get' ) . mockReturnValue ( {
106102 rules : {
107103 endWithDot : true ,
108104 } ,
@@ -118,7 +114,7 @@ describe('commitMeetsRules', () => {
118114 } ) ;
119115
120116 it ( 'should have no dot ending' , ( ) => {
121- getConfigMock . mockReturnValue ( {
117+ jest . spyOn ( Config . prototype , 'config' , 'get' ) . mockReturnValue ( {
122118 rules : {
123119 endWithDot : false ,
124120 } ,
@@ -134,7 +130,7 @@ describe('commitMeetsRules', () => {
134130 } ) ;
135131
136132 it ( 'should have correct length' , ( ) => {
137- getConfigMock . mockReturnValue ( {
133+ jest . spyOn ( Config . prototype , 'config' , 'get' ) . mockReturnValue ( {
138134 rules : {
139135 maxChar : 10 ,
140136 minChar : 8 ,
@@ -152,7 +148,7 @@ describe('commitMeetsRules', () => {
152148 } ) ;
153149
154150 it ( 'should have no length' , ( ) => {
155- getConfigMock . mockReturnValue ( {
151+ jest . spyOn ( Config . prototype , 'config' , 'get' ) . mockReturnValue ( {
156152 types : [
157153 { type : 'Feat' } ,
158154 ] ,
@@ -166,7 +162,7 @@ describe('commitMeetsRules', () => {
166162 } ) ;
167163
168164 it ( 'should have body' , ( ) => {
169- getConfigMock . mockReturnValue ( {
165+ jest . spyOn ( Config . prototype , 'config' , 'get' ) . mockReturnValue ( {
170166 body : true ,
171167 types : [
172168 { type : 'Feat' } ,
@@ -179,7 +175,7 @@ describe('commitMeetsRules', () => {
179175 } ) ;
180176
181177 it ( 'should have initial commit' , ( ) => {
182- getConfigMock . mockReturnValue ( {
178+ jest . spyOn ( Config . prototype , 'config' , 'get' ) . mockReturnValue ( {
183179 initialCommit : {
184180 isEnabled : true ,
185181 message : 'initial commit' ,
@@ -189,7 +185,7 @@ describe('commitMeetsRules', () => {
189185 expect ( commitMeetsRules ( 'initial commit' ) ) . toBe ( true ) ;
190186 expect ( commitMeetsRules ( 'Initial commit' ) ) . toBe ( false ) ;
191187
192- getConfigMock . mockReturnValue ( {
188+ jest . spyOn ( Config . prototype , 'config' , 'get' ) . mockReturnValue ( {
193189 initialCommit : {
194190 isEnabled : false ,
195191 message : 'initial commit' ,
0 commit comments