11import { assert } from "chai" ;
2- import { DeviceAppDataFactory } from "../../../mobile/device-app-data/device-app-data-factory" ;
32import { DevicePlatformsConstants } from "../../../mobile/device-platforms-constants" ;
43import { Errors } from "../../../errors" ;
54import { FileSystem } from "../../../file-system" ;
@@ -19,44 +18,21 @@ temp.track();
1918
2019const testedApplicationIdentifier = "com.telerik.myApp" ;
2120const iOSDeviceProjectRootPath = "/Documents/AppBuilder/LiveSync/app" ;
22- const iOSDeviceSyncZipPath = "/Documents/AppBuilder/LiveSync/sync.zip" ;
2321const androidDeviceProjectRootPath = `${ LiveSyncPaths . ANDROID_TMP_DIR_NAME } /${ LiveSyncPaths . SYNC_DIR_NAME } ` ;
2422
25- class IOSAppIdentifierMock implements Mobile . IDeviceAppData {
26- public platform = "iOS" ;
27- public appIdentifier = testedApplicationIdentifier ;
28- public device : Mobile . IDevice = null ;
29- public getDeviceProjectRootPath = async ( ) => iOSDeviceProjectRootPath ;
30- public deviceSyncZipPath = iOSDeviceSyncZipPath ;
23+ const androidDeviceAppData : Mobile . IDeviceAppData = < any > {
24+ appIdentifier : testedApplicationIdentifier ,
25+ platform : "Android" ,
26+ getDeviceProjectRootPath : async ( ) => androidDeviceProjectRootPath ,
27+ isLiveSyncSupported : async ( ) => true
28+ } ;
3129
32- public async isLiveSyncSupported ( ) : Promise < boolean > {
33- return true ;
34- }
35- }
36-
37- class AndroidAppIdentifierMock implements Mobile . IDeviceAppData {
38- public platform = "Android" ;
39- public appIdentifier = testedApplicationIdentifier ;
40- public device : Mobile . IDevice = null ;
41- public getDeviceProjectRootPath = async ( ) => androidDeviceProjectRootPath ;
42-
43- public async isLiveSyncSupported ( ) : Promise < boolean > {
44- return true ;
45- }
46- }
47-
48- class DeviceAppDataProvider {
49- public createFactoryRules ( ) : IDictionary < Mobile . IDeviceAppDataFactoryRule > {
50- return {
51- iOS : {
52- vanilla : IOSAppIdentifierMock
53- } ,
54- Android : {
55- vanilla : AndroidAppIdentifierMock
56- }
57- } ;
58- }
59- }
30+ const iOSDeviceAppData : Mobile . IDeviceAppData = < any > {
31+ appIdentifier : testedApplicationIdentifier ,
32+ platform : "iOS" ,
33+ getDeviceProjectRootPath : async ( ) => iOSDeviceProjectRootPath ,
34+ isLiveSyncSupported : async ( ) => true
35+ } ;
6036
6137class MobilePlatformsCapabilitiesMock implements Mobile . IPlatformsCapabilities {
6238 public getPlatformNames ( ) : string [ ] {
@@ -84,8 +60,6 @@ class MobilePlatformsCapabilitiesMock implements Mobile.IPlatformsCapabilities {
8460function createTestInjector ( ) : IInjector {
8561 const testInjector = new Yok ( ) ;
8662
87- testInjector . register ( "deviceAppDataFactory" , DeviceAppDataFactory ) ;
88- testInjector . register ( "deviceAppDataProvider" , DeviceAppDataProvider ) ;
8963 testInjector . register ( "devicePlatformsConstants" , DevicePlatformsConstants ) ;
9064 testInjector . register ( "errors" , Errors ) ;
9165 testInjector . register ( "fs" , FileSystem ) ;
@@ -122,20 +96,18 @@ function createFile(testInjector: IInjector, fileToCreate: string, fileContent:
12296}
12397
12498describe ( "Project Files Manager Tests" , ( ) => {
125- let testInjector : IInjector , projectFilesManager : IProjectFilesManager , deviceAppDataFactory : Mobile . IDeviceAppDataFactory ;
99+ let testInjector : IInjector , projectFilesManager : IProjectFilesManager ;
126100 let mobileHelper : Mobile . IMobileHelper ;
127101
128102 beforeEach ( ( ) => {
129103 testInjector = createTestInjector ( ) ;
130104 projectFilesManager = testInjector . resolve ( "projectFilesManager" ) ;
131- deviceAppDataFactory = testInjector . resolve ( "deviceAppDataFactory" ) ;
132105 mobileHelper = testInjector . resolve ( "mobileHelper" ) ;
133106 } ) ;
134107
135108 it ( "maps non-platform specific files to device file paths for ios platform" , async ( ) => {
136- const deviceAppData = deviceAppDataFactory . create ( testedApplicationIdentifier , "iOS" , null ) ;
137109 const files = [ "~/TestApp/app/test.js" , "~/TestApp/app/myfile.js" ] ;
138- const localToDevicePaths = await projectFilesManager . createLocalToDevicePaths ( deviceAppData , "~/TestApp/app" , files , [ ] ) ;
110+ const localToDevicePaths = await projectFilesManager . createLocalToDevicePaths ( iOSDeviceAppData , "~/TestApp/app" , files , [ ] ) ;
139111
140112 _ . each ( localToDevicePaths , ( localToDevicePathData , index ) => {
141113 assert . equal ( files [ index ] , localToDevicePathData . getLocalPath ( ) ) ;
@@ -145,9 +117,8 @@ describe("Project Files Manager Tests", () => {
145117 } ) ;
146118
147119 it ( "maps non-platform specific files to device file paths for android platform" , async ( ) => {
148- const deviceAppData = deviceAppDataFactory . create ( testedApplicationIdentifier , "Android" , null ) ;
149120 const files = [ "~/TestApp/app/test.js" , "~/TestApp/app/myfile.js" ] ;
150- const localToDevicePaths = await projectFilesManager . createLocalToDevicePaths ( deviceAppData , "~/TestApp/app" , files , [ ] ) ;
121+ const localToDevicePaths = await projectFilesManager . createLocalToDevicePaths ( androidDeviceAppData , "~/TestApp/app" , files , [ ] ) ;
151122
152123 _ . each ( localToDevicePaths , ( localToDevicePathData , index ) => {
153124 assert . equal ( files [ index ] , localToDevicePathData . getLocalPath ( ) ) ;
@@ -157,19 +128,17 @@ describe("Project Files Manager Tests", () => {
157128 } ) ;
158129
159130 it ( "maps ios platform specific file to device file path" , async ( ) => {
160- const deviceAppData = deviceAppDataFactory . create ( testedApplicationIdentifier , "iOS" , null ) ;
161131 const filePath = "~/TestApp/app/test.ios.js" ;
162- const localToDevicePathData = ( await projectFilesManager . createLocalToDevicePaths ( deviceAppData , "~/TestApp/app" , [ filePath ] , [ ] ) ) [ 0 ] ;
132+ const localToDevicePathData = ( await projectFilesManager . createLocalToDevicePaths ( iOSDeviceAppData , "~/TestApp/app" , [ filePath ] , [ ] ) ) [ 0 ] ;
163133
164134 assert . equal ( filePath , localToDevicePathData . getLocalPath ( ) ) ;
165135 assert . equal ( mobileHelper . buildDevicePath ( iOSDeviceProjectRootPath , "test.js" ) , localToDevicePathData . getDevicePath ( ) ) ;
166136 assert . equal ( "test.ios.js" , localToDevicePathData . getRelativeToProjectBasePath ( ) ) ;
167137 } ) ;
168138
169139 it ( "maps android platform specific file to device file path" , async ( ) => {
170- const deviceAppData = deviceAppDataFactory . create ( testedApplicationIdentifier , "Android" , null ) ;
171140 const filePath = "~/TestApp/app/test.android.js" ;
172- const localToDevicePathData = ( await projectFilesManager . createLocalToDevicePaths ( deviceAppData , "~/TestApp/app" , [ filePath ] , [ ] ) ) [ 0 ] ;
141+ const localToDevicePathData = ( await projectFilesManager . createLocalToDevicePaths ( androidDeviceAppData , "~/TestApp/app" , [ filePath ] , [ ] ) ) [ 0 ] ;
173142
174143 assert . equal ( filePath , localToDevicePathData . getLocalPath ( ) ) ;
175144 assert . equal ( mobileHelper . buildDevicePath ( androidDeviceProjectRootPath , "test.js" ) , localToDevicePathData . getDevicePath ( ) ) ;
0 commit comments