@@ -63,11 +63,21 @@ describe('ensureReleasedAPILinks', function() {
63
63
} ) ;
64
64
65
65
describe ( 'runCommands' , function ( ) {
66
+ const OPTIONS_REL = {
67
+ libversion : '1.3.0' ,
68
+ chromiumVersion : '80.0.4004.0' ,
69
+ firefoxVersion : '73.0b3' ,
70
+ } ;
71
+ const OPTIONS_DEV = {
72
+ libversion : '1.3.0-post' ,
73
+ chromiumVersion : '<CRVERSION>' ,
74
+ firefoxVersion : '<FFVERSION>' ,
75
+ } ;
66
76
it ( 'should throw for unknown command' , function ( ) {
67
77
const source = new Source ( 'doc.md' , `
68
78
<!-- gen:unknown-command -->something<!-- gen:stop -->
69
79
` ) ;
70
- const messages = runCommands ( [ source ] , '1.1.1' ) ;
80
+ const messages = runCommands ( [ source ] , OPTIONS_REL ) ;
71
81
expect ( source . hasUpdatedText ( ) ) . toBe ( false ) ;
72
82
expect ( messages . length ) . toBe ( 1 ) ;
73
83
expect ( messages [ 0 ] . type ) . toBe ( 'error' ) ;
@@ -78,19 +88,19 @@ describe('runCommands', function() {
78
88
const source = new Source ( 'doc.md' , `
79
89
Playwright <!-- gen:version -->XXX<!-- gen:stop -->
80
90
` ) ;
81
- const messages = runCommands ( [ source ] , '1.2.0' ) ;
91
+ const messages = runCommands ( [ source ] , OPTIONS_REL ) ;
82
92
expect ( messages . length ) . toBe ( 1 ) ;
83
93
expect ( messages [ 0 ] . type ) . toBe ( 'warning' ) ;
84
94
expect ( messages [ 0 ] . text ) . toContain ( 'doc.md' ) ;
85
95
expect ( source . text ( ) ) . toBe ( `
86
- Playwright <!-- gen:version -->v1.2 .0<!-- gen:stop -->
96
+ Playwright <!-- gen:version -->v1.3 .0<!-- gen:stop -->
87
97
` ) ;
88
98
} ) ;
89
99
it ( 'should work for *-post versions' , function ( ) {
90
100
const source = new Source ( 'doc.md' , `
91
101
Playwright <!-- gen:version -->XXX<!-- gen:stop -->
92
102
` ) ;
93
- const messages = runCommands ( [ source ] , '1.2.0-post' ) ;
103
+ const messages = runCommands ( [ source ] , OPTIONS_DEV ) ;
94
104
expect ( messages . length ) . toBe ( 1 ) ;
95
105
expect ( messages [ 0 ] . type ) . toBe ( 'warning' ) ;
96
106
expect ( messages [ 0 ] . text ) . toContain ( 'doc.md' ) ;
@@ -101,12 +111,12 @@ describe('runCommands', function() {
101
111
it ( 'should tolerate different writing' , function ( ) {
102
112
const source = new Source ( 'doc.md' , `Playwright v<!-- gEn:version -->WHAT
103
113
<!-- GEN:stop -->` ) ;
104
- runCommands ( [ source ] , '1.1.1' ) ;
105
- expect ( source . text ( ) ) . toBe ( `Playwright v<!-- gEn:version -->v1.1.1 <!-- GEN:stop -->` ) ;
114
+ runCommands ( [ source ] , OPTIONS_REL ) ;
115
+ expect ( source . text ( ) ) . toBe ( `Playwright v<!-- gEn:version -->v1.3.0 <!-- GEN:stop -->` ) ;
106
116
} ) ;
107
117
it ( 'should not tolerate missing gen:stop' , function ( ) {
108
118
const source = new Source ( 'doc.md' , `<!--GEN:version-->` ) ;
109
- const messages = runCommands ( [ source ] , '1.2.0' ) ;
119
+ const messages = runCommands ( [ source ] , OPTIONS_REL ) ;
110
120
expect ( source . hasUpdatedText ( ) ) . toBe ( false ) ;
111
121
expect ( messages . length ) . toBe ( 1 ) ;
112
122
expect ( messages [ 0 ] . type ) . toBe ( 'error' ) ;
@@ -118,7 +128,7 @@ describe('runCommands', function() {
118
128
const source = new Source ( 'doc.md' , `
119
129
<!-- gen:empty-if-release -->XXX<!-- gen:stop -->
120
130
` ) ;
121
- const messages = runCommands ( [ source ] , '1.1.1' ) ;
131
+ const messages = runCommands ( [ source ] , OPTIONS_REL ) ;
122
132
expect ( messages . length ) . toBe ( 1 ) ;
123
133
expect ( messages [ 0 ] . type ) . toBe ( 'warning' ) ;
124
134
expect ( messages [ 0 ] . text ) . toContain ( 'doc.md' ) ;
@@ -130,7 +140,7 @@ describe('runCommands', function() {
130
140
const source = new Source ( 'doc.md' , `
131
141
<!-- gen:empty-if-release -->XXX<!-- gen:stop -->
132
142
` ) ;
133
- const messages = runCommands ( [ source ] , '1.1.1-post' ) ;
143
+ const messages = runCommands ( [ source ] , OPTIONS_DEV ) ;
134
144
expect ( messages . length ) . toBe ( 0 ) ;
135
145
expect ( source . text ( ) ) . toBe ( `
136
146
<!-- gen:empty-if-release -->XXX<!-- gen:stop -->
@@ -143,7 +153,7 @@ describe('runCommands', function() {
143
153
### class: page
144
154
#### page.$
145
155
#### page.$$` ) ;
146
- const messages = runCommands ( [ source ] , '1.3.0' ) ;
156
+ const messages = runCommands ( [ source ] , OPTIONS_REL ) ;
147
157
expect ( messages . length ) . toBe ( 1 ) ;
148
158
expect ( messages [ 0 ] . type ) . toBe ( 'warning' ) ;
149
159
expect ( messages [ 0 ] . text ) . toContain ( 'doc.md' ) ;
@@ -164,7 +174,7 @@ describe('runCommands', function() {
164
174
# yo comment
165
175
\`\`\`
166
176
` ) ;
167
- const messages = runCommands ( [ source ] , '1.3.0' ) ;
177
+ const messages = runCommands ( [ source ] , OPTIONS_REL ) ;
168
178
expect ( messages . length ) . toBe ( 1 ) ;
169
179
expect ( messages [ 0 ] . type ) . toBe ( 'warning' ) ;
170
180
expect ( messages [ 0 ] . text ) . toContain ( 'doc.md' ) ;
@@ -182,7 +192,7 @@ describe('runCommands', function() {
182
192
const source = new Source ( 'doc.md' , `<!-- gen:toc -->XXX<!-- gen:stop -->
183
193
### some [link](#foobar) here
184
194
` ) ;
185
- const messages = runCommands ( [ source ] , '1.3.0' ) ;
195
+ const messages = runCommands ( [ source ] , OPTIONS_REL ) ;
186
196
expect ( messages . length ) . toBe ( 1 ) ;
187
197
expect ( messages [ 0 ] . type ) . toBe ( 'warning' ) ;
188
198
expect ( messages [ 0 ] . text ) . toContain ( 'doc.md' ) ;
@@ -201,7 +211,7 @@ describe('runCommands', function() {
201
211
#### first.2.1
202
212
## Second
203
213
` ) ;
204
- const messages = runCommands ( [ source ] , '1.3.0' ) ;
214
+ const messages = runCommands ( [ source ] , OPTIONS_REL ) ;
205
215
expect ( messages . length ) . toBe ( 1 ) ;
206
216
expect ( messages [ 0 ] . type ) . toBe ( 'warning' ) ;
207
217
expect ( messages [ 0 ] . text ) . toContain ( 'doc.md' ) ;
@@ -221,20 +231,68 @@ describe('runCommands', function() {
221
231
} ) ;
222
232
it ( 'should work with multiple commands' , function ( ) {
223
233
const source = new Source ( 'doc.md' , `
224
- <!-- gen:version -->XXX <!-- gen:stop -->
225
- <!-- gen:empty-if-release -->YYY <!-- gen:stop -->
226
- <!-- gen:version -->ZZZ <!-- gen:stop -->
234
+ <!-- gen:version -->xxx <!-- gen:stop -->
235
+ <!-- gen:empty-if-release -->yyy <!-- gen:stop -->
236
+ <!-- gen:version -->zzz <!-- gen:stop -->
227
237
` ) ;
228
- const messages = runCommands ( [ source ] , '1.1.1' ) ;
238
+ const messages = runCommands ( [ source ] , OPTIONS_REL ) ;
229
239
expect ( messages . length ) . toBe ( 1 ) ;
230
240
expect ( messages [ 0 ] . type ) . toBe ( 'warning' ) ;
231
241
expect ( messages [ 0 ] . text ) . toContain ( 'doc.md' ) ;
232
242
expect ( source . text ( ) ) . toBe ( `
233
- <!-- gen:version -->v1.1.1 <!-- gen:stop -->
243
+ <!-- gen:version -->v1.3.0 <!-- gen:stop -->
234
244
<!-- gen:empty-if-release --><!-- gen:stop -->
235
- <!-- gen:version -->v1.1.1 <!-- gen:stop -->
245
+ <!-- gen:version -->v1.3.0 <!-- gen:stop -->
236
246
` ) ;
237
247
} ) ;
248
+ describe ( 'gen:chromium-version-if-release' , function ( ) {
249
+ it ( 'should work for release' , function ( ) {
250
+ const source = new Source ( 'doc.md' , `
251
+ Playwright <!-- gen:chromium-version-if-release -->XXX<!-- gen:stop -->
252
+ ` ) ;
253
+ const messages = runCommands ( [ source ] , OPTIONS_REL ) ;
254
+ expect ( messages . length ) . toBe ( 1 ) ;
255
+ expect ( messages [ 0 ] . type ) . toBe ( 'warning' ) ;
256
+ expect ( messages [ 0 ] . text ) . toContain ( 'doc.md' ) ;
257
+ expect ( source . text ( ) ) . toBe ( `
258
+ Playwright <!-- gen:chromium-version-if-release -->80.0.4004.0<!-- gen:stop -->
259
+ ` ) ;
260
+ } ) ;
261
+ it ( 'should be noop for dev' , function ( ) {
262
+ const source = new Source ( 'doc.md' , `
263
+ Playwright <!-- gen:chromium-version-if-release -->XXX<!-- gen:stop -->
264
+ ` ) ;
265
+ const messages = runCommands ( [ source ] , OPTIONS_DEV ) ;
266
+ expect ( messages . length ) . toBe ( 0 ) ;
267
+ expect ( source . text ( ) ) . toBe ( `
268
+ Playwright <!-- gen:chromium-version-if-release -->XXX<!-- gen:stop -->
269
+ ` ) ;
270
+ } ) ;
271
+ } ) ;
272
+ describe ( 'gen:firefox-version' , function ( ) {
273
+ it ( 'should work for release' , function ( ) {
274
+ const source = new Source ( 'doc.md' , `
275
+ Playwright <!-- gen:firefox-version-if-release -->XXX<!-- gen:stop -->
276
+ ` ) ;
277
+ const messages = runCommands ( [ source ] , OPTIONS_REL ) ;
278
+ expect ( messages . length ) . toBe ( 1 ) ;
279
+ expect ( messages [ 0 ] . type ) . toBe ( 'warning' ) ;
280
+ expect ( messages [ 0 ] . text ) . toContain ( 'doc.md' ) ;
281
+ expect ( source . text ( ) ) . toBe ( `
282
+ Playwright <!-- gen:firefox-version-if-release -->73.0b3<!-- gen:stop -->
283
+ ` ) ;
284
+ } ) ;
285
+ it ( 'should be noop for dev' , function ( ) {
286
+ const source = new Source ( 'doc.md' , `
287
+ Playwright <!-- gen:firefox-version-if-release -->XXX<!-- gen:stop -->
288
+ ` ) ;
289
+ const messages = runCommands ( [ source ] , OPTIONS_DEV ) ;
290
+ expect ( messages . length ) . toBe ( 0 ) ;
291
+ expect ( source . text ( ) ) . toBe ( `
292
+ Playwright <!-- gen:firefox-version-if-release -->XXX<!-- gen:stop -->
293
+ ` ) ;
294
+ } ) ;
295
+ } ) ;
238
296
} ) ;
239
297
240
298
runner . run ( ) ;
0 commit comments