@@ -22,7 +22,7 @@ import ChildProcessLib = require("../lib/common/child-process");
22
22
23
23
import path = require( "path" ) ;
24
24
import temp = require( "temp" ) ;
25
- temp . track ( ) ;
25
+ // temp.track();
26
26
27
27
let assert = require ( "chai" ) . assert ;
28
28
@@ -85,15 +85,10 @@ function createProject(testInjector: IInjector, dependencies?: any): string {
85
85
return tempFolder ;
86
86
}
87
87
88
- describe ( "Npm support tests" , ( ) => {
89
- it ( "Ensures that the installed dependencies are prepared correctly" , ( ) => {
90
- let dependencies = {
91
- "bplist" : "0.0.4" ,
92
- "lodash" : "3.9.3"
93
- } ;
94
-
88
+ function setupProject ( ) : IFuture < any > {
89
+ return ( ( ) => {
95
90
let testInjector = createTestInjector ( ) ;
96
- let projectFolder = createProject ( testInjector , dependencies ) ;
91
+ let projectFolder = createProject ( testInjector ) ;
97
92
98
93
let fs = testInjector . resolve ( "fs" ) ;
99
94
@@ -109,7 +104,6 @@ describe("Npm support tests", () => {
109
104
let androidFolderPath = path . join ( projectFolder , "platforms" , "android" ) ;
110
105
fs . ensureDirectoryExists ( androidFolderPath ) . wait ( ) ;
111
106
112
-
113
107
// Mock platform data
114
108
let appDestinationFolderPath = path . join ( androidFolderPath , "assets" ) ;
115
109
let platformsData = testInjector . resolve ( "platformsData" ) ;
@@ -122,8 +116,53 @@ describe("Npm support tests", () => {
122
116
}
123
117
} ;
124
118
125
- let platformService = testInjector . resolve ( "platformService" ) ;
126
- platformService . preparePlatform ( "android" ) . wait ( ) ;
119
+ return {
120
+ testInjector : testInjector ,
121
+ projectFolder : projectFolder ,
122
+ appDestinationFolderPath : appDestinationFolderPath ,
123
+ } ;
124
+ } ) . future < any > ( ) ( ) ;
125
+ }
126
+
127
+ function addDependencies ( testInjector : IInjector , projectFolder : string , dependencies : any ) : IFuture < void > {
128
+ return ( ( ) => {
129
+ let fs = testInjector . resolve ( "fs" ) ;
130
+ let packageJsonPath = path . join ( projectFolder , "package.json" ) ;
131
+ let packageJsonData = fs . readJson ( packageJsonPath ) . wait ( ) ;
132
+
133
+ let currentDependencies = packageJsonData . dependencies ;
134
+ console . log ( "currentDependencies!!!!" ) ;
135
+ console . log ( currentDependencies ) ;
136
+ _ . extend ( currentDependencies , dependencies ) ;
137
+
138
+ console . log ( "extendedDependencies!!!!!!" ) ;
139
+ console . log ( currentDependencies ) ;
140
+
141
+ console . log ( "PACKAGE JSON DATA BEFORE WRITE!!!" ) ;
142
+ console . log ( packageJsonData ) ;
143
+ fs . writeJson ( packageJsonPath , packageJsonData ) . wait ( ) ;
144
+ } ) . future < void > ( ) ( ) ;
145
+ }
146
+
147
+ function preparePlatform ( testInjector : IInjector ) : IFuture < void > {
148
+ let platformService = testInjector . resolve ( "platformService" ) ;
149
+ return platformService . preparePlatform ( "android" ) ;
150
+ }
151
+
152
+ describe ( "Npm support tests" , ( ) => {
153
+ let testInjector : IInjector , projectFolder : string , appDestinationFolderPath : string ;
154
+ before ( ( ) => {
155
+ let projectSetup = setupProject ( ) . wait ( ) ;
156
+ testInjector = projectSetup . testInjector ;
157
+ projectFolder = projectSetup . projectFolder ;
158
+ appDestinationFolderPath = projectSetup . appDestinationFolderPath ;
159
+ } ) ;
160
+ it ( "Ensures that the installed dependencies are prepared correctly" , ( ) => {
161
+ // Setup
162
+ addDependencies ( testInjector , projectFolder , { "bplist" : "0.0.4" } ) . wait ( ) ;
163
+
164
+ // Act
165
+ preparePlatform ( testInjector ) . wait ( ) ;
127
166
128
167
// Assert
129
168
let tnsModulesFolderPath = path . join ( appDestinationFolderPath , "app" , "tns_modules" ) ;
@@ -132,6 +171,7 @@ describe("Npm support tests", () => {
132
171
let bplistCreatorFolderPath = path . join ( tnsModulesFolderPath , "bplist-creator" ) ;
133
172
let bplistParserFolderPath = path . join ( tnsModulesFolderPath , "bplist-parser" ) ;
134
173
174
+ let fs = testInjector . resolve ( "fs" ) ;
135
175
assert . isTrue ( fs . exists ( lodashFolderPath ) . wait ( ) ) ;
136
176
assert . isTrue ( fs . exists ( bplistFolderPath ) . wait ( ) ) ;
137
177
assert . isTrue ( fs . exists ( bplistCreatorFolderPath ) . wait ( ) ) ;
0 commit comments