@@ -14,6 +14,16 @@ test('should bump version if same tag is available', () => {
14
14
expect ( nextVersion ) . toBe ( '0.0.1-preview.1' ) ;
15
15
} ) ;
16
16
17
+ test ( 'should bump version if same tag is available but prefixed' , ( ) => {
18
+ const nextVersion = getNextVersion ( 'v0.0.1-preview.0' , [ '0.0.1-preview.0' ] ) ;
19
+ expect ( nextVersion ) . toBe ( '0.0.1-preview.1' ) ;
20
+ } ) ;
21
+
22
+ test ( 'should bump version if same tag is available but not prefixed' , ( ) => {
23
+ const nextVersion = getNextVersion ( '0.0.1-preview.0' , [ 'v0.0.1-preview.0' ] ) ;
24
+ expect ( nextVersion ) . toBe ( '0.0.1-preview.1' ) ;
25
+ } ) ;
26
+
17
27
test ( 'should use bump latest pre-release tag if multiple tags are available' , async ( ) => {
18
28
const nextVersion = getNextVersion ( '0.0.1-preview.0' , [ '0.0.1-preview.1' , '0.0.1-preview.0' ] ) ;
19
29
expect ( nextVersion ) . toBe ( '0.0.1-preview.2' ) ;
@@ -62,3 +72,24 @@ test('should bump final version if tag already exists and ends with 0', () => {
62
72
] ) ;
63
73
expect ( nextVersion ) . toBe ( '0.2.1' ) ;
64
74
} ) ;
75
+
76
+ test ( 'should throw an error if final version is already tagged and does not end with 0' , ( ) => {
77
+ const nextVersion = ( ) => getNextVersion ( '0.2.1' , [
78
+ '0.2.1' ,
79
+ ] ) ;
80
+ expect ( nextVersion ) . toThrow ( Error ) ;
81
+ } ) ;
82
+
83
+ test ( 'should throw an error if pre-release version is already tagged and does not end with 0' , ( ) => {
84
+ const nextVersion = ( ) => getNextVersion ( '0.2.0-preview.1' , [
85
+ '0.2.0-preview.1' ,
86
+ ] ) ;
87
+ expect ( nextVersion ) . toThrow ( Error ) ;
88
+ } ) ;
89
+
90
+ test ( 'should throw an error for wrong versions' , ( ) => {
91
+ expect ( ( ) => getNextVersion ( 'xyz' , [ ] ) ) . toThrow ( Error ) ;
92
+ expect ( ( ) => getNextVersion ( '1.0' , [ ] ) ) . toThrow ( Error ) ;
93
+ expect ( ( ) => getNextVersion ( '~1.0.0' , [ ] ) ) . toThrow ( Error ) ;
94
+ } ) ;
95
+
0 commit comments