@@ -3,48 +3,52 @@ import { getMaxChangeType, initializePackageChangeTypes } from '../../changefile
33import type { ChangeSet } from '../../types/ChangeInfo' ;
44
55describe ( 'getMaxChangeType' , ( ) => {
6+ it ( 'handles empty change type array' , ( ) => {
7+ expect ( getMaxChangeType ( [ ] , null ) ) . toBe ( 'none' ) ;
8+ } ) ;
9+
10+ it ( 'handles single change type' , ( ) => {
11+ expect ( getMaxChangeType ( [ 'patch' ] , null ) ) . toBe ( 'patch' ) ;
12+ } ) ;
13+
614 it ( 'handles equal change types' , ( ) => {
7- const changeType = getMaxChangeType ( 'patch' , 'patch' , null ) ;
15+ const changeType = getMaxChangeType ( [ 'patch' , 'patch' ] , null ) ;
816 expect ( changeType ) . toBe ( 'patch' ) ;
917 } ) ;
1018
1119 it ( 'returns greater change type without disallowedChangeTypes' , ( ) => {
12- expect ( getMaxChangeType ( 'patch' , 'minor' , null ) ) . toBe ( 'minor' ) ;
13- expect ( getMaxChangeType ( 'minor' , 'patch' , null ) ) . toBe ( 'minor' ) ;
14- expect ( getMaxChangeType ( 'minor' , 'major' , null ) ) . toBe ( 'major' ) ;
15- expect ( getMaxChangeType ( 'patch' , 'major' , null ) ) . toBe ( 'major' ) ;
16- expect ( getMaxChangeType ( 'patch' , 'prerelease' , null ) ) . toBe ( 'patch' ) ;
17- expect ( getMaxChangeType ( 'patch' , 'none' , null ) ) . toBe ( 'patch' ) ;
18- expect ( getMaxChangeType ( 'prerelease' , 'none' , null ) ) . toBe ( 'prerelease' ) ;
20+ expect ( getMaxChangeType ( [ 'patch' , 'minor' ] , null ) ) . toBe ( 'minor' ) ;
21+ expect ( getMaxChangeType ( [ 'minor' , 'patch' ] , null ) ) . toBe ( 'minor' ) ;
22+ expect ( getMaxChangeType ( [ 'minor' , 'major' ] , null ) ) . toBe ( 'major' ) ;
23+ expect ( getMaxChangeType ( [ 'patch' , 'major' ] , null ) ) . toBe ( 'major' ) ;
24+ expect ( getMaxChangeType ( [ 'patch' , 'prerelease' ] , null ) ) . toBe ( 'patch' ) ;
25+ expect ( getMaxChangeType ( [ 'patch' , 'none' ] , null ) ) . toBe ( 'patch' ) ;
26+ expect ( getMaxChangeType ( [ 'prerelease' , 'none' ] , null ) ) . toBe ( 'prerelease' ) ;
27+ } ) ;
28+
29+ it ( 'handles longer array of changeTypes with max in middle' , ( ) => {
30+ const changeType = getMaxChangeType ( [ 'patch' , 'minor' , 'major' , 'patch' ] , null ) ;
31+ expect ( changeType ) . toBe ( 'major' ) ;
1932 } ) ;
2033
2134 it ( 'returns none if all given change types are disallowed' , ( ) => {
22- const changeType = getMaxChangeType ( 'patch' , 'major' , [
23- 'major' ,
24- 'minor' ,
25- 'patch' ,
26- 'prerelease' ,
27- 'premajor' ,
28- 'preminor' ,
29- 'prepatch' ,
30- ] ) ;
35+ const changeType = getMaxChangeType (
36+ [ 'patch' , 'major' ] ,
37+ [ 'major' , 'minor' , 'patch' , 'prerelease' , 'premajor' , 'preminor' , 'prepatch' ]
38+ ) ;
3139 expect ( changeType ) . toBe ( 'none' ) ;
3240 } ) ;
3341
3442 it ( 'returns next greatest change type if max is disallowed' , ( ) => {
35- const changeType = getMaxChangeType ( 'patch' , 'major' , [ 'major' , 'premajor' , 'preminor' , 'prepatch' ] ) ;
43+ const changeType = getMaxChangeType ( [ 'patch' , 'major' ] , [ 'major' , 'premajor' , 'preminor' , 'prepatch' ] ) ;
3644 expect ( changeType ) . toBe ( 'minor' ) ;
3745 } ) ;
3846
3947 it ( 'handles prerelease only case' , ( ) => {
40- const changeType = getMaxChangeType ( 'patch' , 'major' , [
41- 'major' ,
42- 'minor' ,
43- 'patch' ,
44- 'premajor' ,
45- 'preminor' ,
46- 'prepatch' ,
47- ] ) ;
48+ const changeType = getMaxChangeType (
49+ [ 'patch' , 'major' ] ,
50+ [ 'major' , 'minor' , 'patch' , 'premajor' , 'preminor' , 'prepatch' ]
51+ ) ;
4852 expect ( changeType ) . toBe ( 'prerelease' ) ;
4953 } ) ;
5054} ) ;
0 commit comments