@@ -2,6 +2,7 @@ import * as yok from "../lib/common/yok";
2
2
import * as stubs from "./stubs" ;
3
3
import * as PlatformServiceLib from "../lib/services/platform-service" ;
4
4
import * as StaticConfigLib from "../lib/config" ;
5
+ import { VERSION_STRING } from "../lib/constants" ;
5
6
import * as fsLib from "../lib/common/file-system" ;
6
7
import * as optionsLib from "../lib/options" ;
7
8
import * as hostInfoLib from "../lib/common/host-info" ;
@@ -129,6 +130,45 @@ describe('Platform Service Tests', () => {
129
130
assert . equal ( errorMessage , err . message ) ;
130
131
}
131
132
} ) ;
133
+ it ( "should respect platform version in package.json's nativescript key" , async ( ) => {
134
+ const versionString = "2.5.0" ;
135
+ let fs = testInjector . resolve ( "fs" ) ;
136
+ fs . exists = ( ) => false ;
137
+
138
+ let nsValueObject : any = { } ;
139
+ nsValueObject [ VERSION_STRING ] = versionString ;
140
+ let projectDataService = testInjector . resolve ( "projectDataService" ) ;
141
+ projectDataService . getNSValue = ( ) => nsValueObject ;
142
+
143
+ let npmInstallationManager = testInjector . resolve ( "npmInstallationManager" ) ;
144
+ npmInstallationManager . install = ( packageName : string , packageDir : string , options : INpmInstallOptions ) => {
145
+ assert . deepEqual ( options . version , versionString ) ;
146
+ return "" ;
147
+ } ;
148
+
149
+ let projectData : IProjectData = testInjector . resolve ( "projectData" ) ;
150
+
151
+ await platformService . addPlatforms ( [ "android" ] , "" , projectData , null ) ;
152
+ await platformService . addPlatforms ( [ "ios" ] , "" , projectData , null ) ;
153
+ } ) ;
154
+ it ( "should install latest platform if no information found in package.json's nativescript key" , async ( ) => {
155
+ let fs = testInjector . resolve ( "fs" ) ;
156
+ fs . exists = ( ) => false ;
157
+
158
+ let projectDataService = testInjector . resolve ( "projectDataService" ) ;
159
+ projectDataService . getNSValue = ( ) : any => null ;
160
+
161
+ let npmInstallationManager = testInjector . resolve ( "npmInstallationManager" ) ;
162
+ npmInstallationManager . install = ( packageName : string , packageDir : string , options : INpmInstallOptions ) => {
163
+ assert . deepEqual ( options . version , undefined ) ;
164
+ return "" ;
165
+ } ;
166
+
167
+ let projectData : IProjectData = testInjector . resolve ( "projectData" ) ;
168
+
169
+ await platformService . addPlatforms ( [ "android" ] , "" , projectData , null ) ;
170
+ await platformService . addPlatforms ( [ "ios" ] , "" , projectData , null ) ;
171
+ } ) ;
132
172
} ) ;
133
173
describe ( "#add platform(ios)" , ( ) => {
134
174
it ( "should call validate method" , async ( ) => {
@@ -173,7 +213,7 @@ describe('Platform Service Tests', () => {
173
213
} ) ;
174
214
175
215
describe ( "remove platform unit tests" , ( ) => {
176
- it ( "should fail when platforms are not added" , async ( ) => {
216
+ it ( "should fail when platforms are not added" , async ( ) => {
177
217
const ExpectedErrorsCaught = 2 ;
178
218
let errorsCaught = 0 ;
179
219
let projectData : IProjectData = testInjector . resolve ( "projectData" ) ;
0 commit comments