@@ -135,5 +135,89 @@ describe('Unit: resolveVersion', function () {
135
135
expect ( error . message ) . to . equal ( 'No valid versions found.' ) ;
136
136
} ) ;
137
137
} ) ;
138
+
139
+ describe ( 'jump to next major' , function ( ) {
140
+ it ( 'throws error if you aren\'t on the latest v1' , function ( ) {
141
+ stubYarn ( '{"data": ["1.23.0", "1.24.0", "1.25.0", "2.0.0"]}' ) ;
142
+
143
+ return resolveVersion ( null , '1.24.0' , false ) . then ( function ( ) {
144
+ throw new Error ( 'Version finder should not have resolved' ) ;
145
+ } ) . catch ( function ( error ) {
146
+ expect ( error ) . to . be . an . instanceOf ( Error ) ;
147
+ expect ( error . message ) . to . equal ( 'You are about to migrate to Ghost 2.0. Your blog is not on the latest Ghost 1.0 version.' ) ;
148
+ } ) ;
149
+ } ) ;
150
+
151
+ it ( 'resolves if you are on the latest v1' , function ( ) {
152
+ stubYarn ( '{"data": ["1.23.0", "1.25.1", "1.25.2", "2.0.0"]}' ) ;
153
+
154
+ return resolveVersion ( null , '1.25.2' , false )
155
+ . then ( function ( version ) {
156
+ expect ( version ) . to . eql ( '2.0.0' ) ;
157
+ } ) ;
158
+ } ) ;
159
+
160
+ it ( 'resolves using `--v1` and you are\'t on the latest v1' , function ( ) {
161
+ stubYarn ( '{"data": ["1.23.0", "1.25.1", "1.25.2", "2.0.0"]}' ) ;
162
+
163
+ return resolveVersion ( null , '1.25.1' , true )
164
+ . then ( function ( version ) {
165
+ expect ( version ) . to . eql ( '1.25.2' ) ;
166
+ } ) ;
167
+ } ) ;
168
+
169
+ it ( 'force updating' , function ( ) {
170
+ stubYarn ( '{"data": ["1.23.0", "1.25.1", "1.25.2", "2.0.0"]}' ) ;
171
+
172
+ return resolveVersion ( null , '1.25.2' , false , true )
173
+ . then ( function ( version ) {
174
+ expect ( version ) . to . eql ( '1.25.2' ) ;
175
+ } ) ;
176
+ } ) ;
177
+
178
+ it ( 'force updating with `--v1`' , function ( ) {
179
+ stubYarn ( '{"data": ["1.23.0", "1.25.1", "1.25.2", "2.0.0"]}' ) ;
180
+
181
+ return resolveVersion ( null , '1.25.1' , true , true )
182
+ . then ( function ( version ) {
183
+ expect ( version ) . to . eql ( '1.25.2' ) ;
184
+ } ) ;
185
+ } ) ;
186
+
187
+ it ( 'force updating with many v2 releases' , function ( ) {
188
+ stubYarn ( '{"data": ["1.23.0", "1.25.1", "1.25.2", "2.0.0", "2.1.0", "2.2.0"]}' ) ;
189
+
190
+ return resolveVersion ( null , '1.25.1' , false , true )
191
+ . then ( function ( version ) {
192
+ expect ( version ) . to . eql ( '1.25.2' ) ;
193
+ } ) ;
194
+ } ) ;
195
+
196
+ it ( 'throws error if you want to force updating to a previous major' , function ( ) {
197
+ stubYarn ( '{"data": ["1.23.0", "1.25.1", "1.25.2", "2.0.0"]}' ) ;
198
+
199
+ return resolveVersion ( null , '2.0.0' , true , true )
200
+ . then ( function ( ) {
201
+ throw new Error ( 'Version finder should not have resolved' ) ;
202
+ } )
203
+ . catch ( function ( error ) {
204
+ expect ( error ) . to . be . an . instanceOf ( Error ) ;
205
+ expect ( error . message ) . to . equal ( 'You can\'t downgrade from v2 to v1 using these options.' ) ;
206
+ } ) ;
207
+ } ) ;
208
+
209
+ it ( 'throws error if you want to update to a previous major' , function ( ) {
210
+ stubYarn ( '{"data": ["1.23.0", "1.25.1", "1.25.2", "2.0.0"]}' ) ;
211
+
212
+ return resolveVersion ( null , '2.0.0' , true , false )
213
+ . then ( function ( ) {
214
+ throw new Error ( 'Version finder should not have resolved' ) ;
215
+ } )
216
+ . catch ( function ( error ) {
217
+ expect ( error ) . to . be . an . instanceOf ( Error ) ;
218
+ expect ( error . message ) . to . equal ( 'No valid versions found.' ) ;
219
+ } ) ;
220
+ } ) ;
221
+ } ) ;
138
222
} ) ;
139
223
} ) ;
0 commit comments