@@ -9,8 +9,8 @@ jest.mock('os');
9
9
jest . mock ( 'git-rev-sync' ) ;
10
10
11
11
describe ( 'version-from-git-tag' , ( ) => {
12
- const hash = 'g9234bfb' ;
13
12
describe ( 'with no tag' , ( ) => {
13
+ const hash = '9234bfb' ;
14
14
const gitDescribe = {
15
15
hash,
16
16
} ;
@@ -52,95 +52,19 @@ describe('version-from-git-tag', () => {
52
52
} ) ;
53
53
} ) ;
54
54
55
- describe ( 'with no semver' , ( ) => {
56
- const tag = 'sometag' ;
57
- const gitDescribe = {
58
- tag,
59
- hash,
60
- } ;
61
- describe ( 'when the repo is not on an exact tag' , ( ) => {
62
- const distance = 1 ;
63
- describe ( 'when the repo is dirty' , ( ) => {
64
- const dirty = true ;
65
- beforeEach ( ( ) => {
66
- ( gitDescribeSync as jest . Mock ) . mockReturnValue ( {
67
- ...gitDescribe ,
68
- dirty,
69
- distance,
70
- } ) ;
71
- } ) ;
72
- it ( 'displays the version number correctly' , ( ) => {
73
- expect ( versionFromGitTag ( ) ) . toEqual (
74
- 'sometag-featwhatever+1.9234bfb.SNAPSHOT.HOSTNAME'
75
- ) ;
76
- } ) ;
77
- } ) ;
78
- describe ( 'when the repo is not dirty' , ( ) => {
79
- const dirty = false ;
80
- beforeEach ( ( ) => {
81
- ( gitDescribeSync as jest . Mock ) . mockReturnValue ( {
82
- ...gitDescribe ,
83
- dirty,
84
- distance,
85
- } ) ;
86
- } ) ;
87
- it ( 'displays the version number correctly' , ( ) => {
88
- expect ( versionFromGitTag ( ) ) . toEqual ( 'sometag-featwhatever+1.9234bfb' ) ;
89
- } ) ;
90
- } ) ;
91
- } ) ;
92
- describe ( 'when the repo is on an exact tag' , ( ) => {
93
- const distance = 0 ;
94
- describe ( 'when the repo is dirty' , ( ) => {
95
- const dirty = true ;
96
- beforeEach ( ( ) => {
97
- ( gitDescribeSync as jest . Mock ) . mockReturnValue ( {
98
- ...gitDescribe ,
99
- dirty,
100
- distance,
101
- } ) ;
102
- } ) ;
103
- it ( 'displays the version number correctly' , ( ) => {
104
- expect ( versionFromGitTag ( ) ) . toEqual (
105
- 'sometag-featwhatever+0.9234bfb.SNAPSHOT.HOSTNAME'
106
- ) ;
107
- } ) ;
108
- } ) ;
109
- describe ( 'when the repo is not dirty' , ( ) => {
110
- const dirty = false ;
111
- beforeEach ( ( ) => {
112
- ( gitDescribeSync as jest . Mock ) . mockReturnValue ( {
113
- ...gitDescribe ,
114
- dirty,
115
- distance,
116
- } ) ;
117
- } ) ;
118
- it ( 'displays the version number correctly' , ( ) => {
119
- expect ( versionFromGitTag ( ) ) . toEqual ( 'sometag' ) ;
120
- } ) ;
121
- } ) ;
122
- } ) ;
123
- } ) ;
124
-
125
- describe ( 'with a release version' , ( ) => {
126
- const version = '1.2.3' ;
127
- const tag = `v${ version } ` ;
128
- const gitDescribe = {
129
- hash,
130
- tag,
131
- semver : {
132
- version,
133
- } ,
134
- } ;
135
-
136
- describe ( 'when on a branch named feat/whatever' , ( ) => {
137
- ( branch as jest . Mock ) . mockReturnValue ( 'feat/whatever' ) ;
55
+ describe ( 'with a tag' , ( ) => {
56
+ const hash = 'g9234bfb' ;
138
57
58
+ describe ( 'with no semver' , ( ) => {
59
+ const tag = 'sometag' ;
60
+ const gitDescribe = {
61
+ tag,
62
+ hash,
63
+ } ;
139
64
describe ( 'when the repo is not on an exact tag' , ( ) => {
140
65
const distance = 1 ;
141
66
describe ( 'when the repo is dirty' , ( ) => {
142
67
const dirty = true ;
143
-
144
68
beforeEach ( ( ) => {
145
69
( gitDescribeSync as jest . Mock ) . mockReturnValue ( {
146
70
...gitDescribe ,
@@ -150,7 +74,7 @@ describe('version-from-git-tag', () => {
150
74
} ) ;
151
75
it ( 'displays the version number correctly' , ( ) => {
152
76
expect ( versionFromGitTag ( ) ) . toEqual (
153
- '1.2.3 -featwhatever+1.9234bfb.SNAPSHOT.HOSTNAME'
77
+ 'sometag -featwhatever+1.9234bfb.SNAPSHOT.HOSTNAME'
154
78
) ;
155
79
} ) ;
156
80
} ) ;
@@ -164,7 +88,9 @@ describe('version-from-git-tag', () => {
164
88
} ) ;
165
89
} ) ;
166
90
it ( 'displays the version number correctly' , ( ) => {
167
- expect ( versionFromGitTag ( ) ) . toEqual ( '1.2.3-featwhatever+1.9234bfb' ) ;
91
+ expect ( versionFromGitTag ( ) ) . toEqual (
92
+ 'sometag-featwhatever+1.9234bfb'
93
+ ) ;
168
94
} ) ;
169
95
} ) ;
170
96
} ) ;
@@ -181,7 +107,7 @@ describe('version-from-git-tag', () => {
181
107
} ) ;
182
108
it ( 'displays the version number correctly' , ( ) => {
183
109
expect ( versionFromGitTag ( ) ) . toEqual (
184
- '1.2.3 -featwhatever+0.9234bfb.SNAPSHOT.HOSTNAME'
110
+ 'sometag -featwhatever+0.9234bfb.SNAPSHOT.HOSTNAME'
185
111
) ;
186
112
} ) ;
187
113
} ) ;
@@ -195,84 +121,166 @@ describe('version-from-git-tag', () => {
195
121
} ) ;
196
122
} ) ;
197
123
it ( 'displays the version number correctly' , ( ) => {
198
- expect ( versionFromGitTag ( ) ) . toEqual ( '1.2.3 ' ) ;
124
+ expect ( versionFromGitTag ( ) ) . toEqual ( 'sometag ' ) ;
199
125
} ) ;
200
126
} ) ;
201
127
} ) ;
202
128
} ) ;
203
- } ) ;
204
- describe ( 'with a prerelease version' , ( ) => {
205
- const version = '1.2.3-beta' ;
206
- const tag = `v${ version } ` ;
207
- const gitDescribe = {
208
- hash,
209
- tag,
210
- semver : {
211
- version,
212
- } ,
213
- } ;
214
- describe ( 'when the repo is not on an exact tag' , ( ) => {
215
- const distance = 1 ;
216
- describe ( 'when the repo is dirty' , ( ) => {
217
- const dirty = true ;
218
129
219
- beforeEach ( ( ) => {
220
- ( gitDescribeSync as jest . Mock ) . mockReturnValue ( {
221
- ...gitDescribe ,
222
- dirty,
223
- distance,
130
+ describe ( 'with a release version' , ( ) => {
131
+ const version = '1.2.3' ;
132
+ const tag = `v${ version } ` ;
133
+ const gitDescribe = {
134
+ hash,
135
+ tag,
136
+ semver : {
137
+ version,
138
+ } ,
139
+ } ;
140
+
141
+ describe ( 'when on a branch named feat/whatever' , ( ) => {
142
+ ( branch as jest . Mock ) . mockReturnValue ( 'feat/whatever' ) ;
143
+
144
+ describe ( 'when the repo is not on an exact tag' , ( ) => {
145
+ const distance = 1 ;
146
+ describe ( 'when the repo is dirty' , ( ) => {
147
+ const dirty = true ;
148
+
149
+ beforeEach ( ( ) => {
150
+ ( gitDescribeSync as jest . Mock ) . mockReturnValue ( {
151
+ ...gitDescribe ,
152
+ dirty,
153
+ distance,
154
+ } ) ;
155
+ } ) ;
156
+ it ( 'displays the version number correctly' , ( ) => {
157
+ expect ( versionFromGitTag ( ) ) . toEqual (
158
+ '1.2.3-featwhatever+1.9234bfb.SNAPSHOT.HOSTNAME'
159
+ ) ;
160
+ } ) ;
224
161
} ) ;
225
- } ) ;
226
- it ( 'displays the version number correctly' , ( ) => {
227
- expect ( versionFromGitTag ( ) ) . toEqual (
228
- '1.2.3-beta.featwhatever+1.9234bfb.SNAPSHOT.HOSTNAME'
229
- ) ;
230
- } ) ;
231
- } ) ;
232
- describe ( 'when the repo is not dirty' , ( ) => {
233
- const dirty = false ;
234
- beforeEach ( ( ) => {
235
- ( gitDescribeSync as jest . Mock ) . mockReturnValue ( {
236
- ... gitDescribe ,
237
- dirty ,
238
- distance ,
162
+ describe ( 'when the repo is not dirty' , ( ) => {
163
+ const dirty = false ;
164
+ beforeEach ( ( ) => {
165
+ ( gitDescribeSync as jest . Mock ) . mockReturnValue ( {
166
+ ... gitDescribe ,
167
+ dirty ,
168
+ distance ,
169
+ } ) ;
170
+ } ) ;
171
+ it ( 'displays the version number correctly' , ( ) => {
172
+ expect ( versionFromGitTag ( ) ) . toEqual (
173
+ '1.2.3-featwhatever+1.9234bfb'
174
+ ) ;
175
+ } ) ;
239
176
} ) ;
240
177
} ) ;
241
- it ( 'displays the version number correctly' , ( ) => {
242
- expect ( versionFromGitTag ( ) ) . toEqual (
243
- '1.2.3-beta.featwhatever+1.9234bfb'
244
- ) ;
178
+ describe ( 'when the repo is on an exact tag' , ( ) => {
179
+ const distance = 0 ;
180
+ describe ( 'when the repo is dirty' , ( ) => {
181
+ const dirty = true ;
182
+ beforeEach ( ( ) => {
183
+ ( gitDescribeSync as jest . Mock ) . mockReturnValue ( {
184
+ ...gitDescribe ,
185
+ dirty,
186
+ distance,
187
+ } ) ;
188
+ } ) ;
189
+ it ( 'displays the version number correctly' , ( ) => {
190
+ expect ( versionFromGitTag ( ) ) . toEqual (
191
+ '1.2.3-featwhatever+0.9234bfb.SNAPSHOT.HOSTNAME'
192
+ ) ;
193
+ } ) ;
194
+ } ) ;
195
+ describe ( 'when the repo is not dirty' , ( ) => {
196
+ const dirty = false ;
197
+ beforeEach ( ( ) => {
198
+ ( gitDescribeSync as jest . Mock ) . mockReturnValue ( {
199
+ ...gitDescribe ,
200
+ dirty,
201
+ distance,
202
+ } ) ;
203
+ } ) ;
204
+ it ( 'displays the version number correctly' , ( ) => {
205
+ expect ( versionFromGitTag ( ) ) . toEqual ( '1.2.3' ) ;
206
+ } ) ;
207
+ } ) ;
245
208
} ) ;
246
209
} ) ;
247
210
} ) ;
248
- describe ( 'when the repo is on an exact tag' , ( ) => {
249
- const distance = 0 ;
250
- describe ( 'when the repo is dirty' , ( ) => {
251
- const dirty = true ;
252
- beforeEach ( ( ) => {
253
- ( gitDescribeSync as jest . Mock ) . mockReturnValue ( {
254
- ...gitDescribe ,
255
- dirty,
256
- distance,
211
+ describe ( 'with a prerelease version' , ( ) => {
212
+ const version = '1.2.3-beta' ;
213
+ const tag = `v${ version } ` ;
214
+ const gitDescribe = {
215
+ hash,
216
+ tag,
217
+ semver : {
218
+ version,
219
+ } ,
220
+ } ;
221
+ describe ( 'when the repo is not on an exact tag' , ( ) => {
222
+ const distance = 1 ;
223
+ describe ( 'when the repo is dirty' , ( ) => {
224
+ const dirty = true ;
225
+
226
+ beforeEach ( ( ) => {
227
+ ( gitDescribeSync as jest . Mock ) . mockReturnValue ( {
228
+ ...gitDescribe ,
229
+ dirty,
230
+ distance,
231
+ } ) ;
232
+ } ) ;
233
+ it ( 'displays the version number correctly' , ( ) => {
234
+ expect ( versionFromGitTag ( ) ) . toEqual (
235
+ '1.2.3-beta.featwhatever+1.9234bfb.SNAPSHOT.HOSTNAME'
236
+ ) ;
257
237
} ) ;
258
238
} ) ;
259
- it ( 'displays the version number correctly' , ( ) => {
260
- expect ( versionFromGitTag ( ) ) . toEqual (
261
- '1.2.3-beta.featwhatever+0.9234bfb.SNAPSHOT.HOSTNAME'
262
- ) ;
239
+ describe ( 'when the repo is not dirty' , ( ) => {
240
+ const dirty = false ;
241
+ beforeEach ( ( ) => {
242
+ ( gitDescribeSync as jest . Mock ) . mockReturnValue ( {
243
+ ...gitDescribe ,
244
+ dirty,
245
+ distance,
246
+ } ) ;
247
+ } ) ;
248
+ it ( 'displays the version number correctly' , ( ) => {
249
+ expect ( versionFromGitTag ( ) ) . toEqual (
250
+ '1.2.3-beta.featwhatever+1.9234bfb'
251
+ ) ;
252
+ } ) ;
263
253
} ) ;
264
254
} ) ;
265
- describe ( 'when the repo is not dirty' , ( ) => {
266
- const dirty = false ;
267
- beforeEach ( ( ) => {
268
- ( gitDescribeSync as jest . Mock ) . mockReturnValue ( {
269
- ...gitDescribe ,
270
- dirty,
271
- distance,
255
+ describe ( 'when the repo is on an exact tag' , ( ) => {
256
+ const distance = 0 ;
257
+ describe ( 'when the repo is dirty' , ( ) => {
258
+ const dirty = true ;
259
+ beforeEach ( ( ) => {
260
+ ( gitDescribeSync as jest . Mock ) . mockReturnValue ( {
261
+ ...gitDescribe ,
262
+ dirty,
263
+ distance,
264
+ } ) ;
265
+ } ) ;
266
+ it ( 'displays the version number correctly' , ( ) => {
267
+ expect ( versionFromGitTag ( ) ) . toEqual (
268
+ '1.2.3-beta.featwhatever+0.9234bfb.SNAPSHOT.HOSTNAME'
269
+ ) ;
272
270
} ) ;
273
271
} ) ;
274
- it ( 'displays the version number correctly' , ( ) => {
275
- expect ( versionFromGitTag ( ) ) . toEqual ( '1.2.3-beta' ) ;
272
+ describe ( 'when the repo is not dirty' , ( ) => {
273
+ const dirty = false ;
274
+ beforeEach ( ( ) => {
275
+ ( gitDescribeSync as jest . Mock ) . mockReturnValue ( {
276
+ ...gitDescribe ,
277
+ dirty,
278
+ distance,
279
+ } ) ;
280
+ } ) ;
281
+ it ( 'displays the version number correctly' , ( ) => {
282
+ expect ( versionFromGitTag ( ) ) . toEqual ( '1.2.3-beta' ) ;
283
+ } ) ;
276
284
} ) ;
277
285
} ) ;
278
286
} ) ;
0 commit comments