4
4
from core .osutils .command import run
5
5
from core .osutils .file import File
6
6
from core .osutils .folder import Folder
7
- from core .settings .settings import ANDROID_RUNTIME_PATH , TNS_PATH , IOS_RUNTIME_SYMLINK_PATH , CURRENT_OS , OSType , \
8
- SUT_ROOT_FOLDER , TEST_RUN_HOME
7
+ from core .settings .settings import ANDROID_RUNTIME_PATH , CURRENT_OS , IOS_RUNTIME_SYMLINK_PATH , OSType , \
8
+ TEST_RUN_HOME , TNS_PATH
9
9
from core .tns .tns import Tns
10
10
11
11
@@ -28,18 +28,13 @@ def tearDown(self):
28
28
def tearDownClass (cls ):
29
29
Folder .cleanup ('TNS_App' )
30
30
31
- unittest .skip ("" )
32
31
def test_001_transpilation_typescript (self ):
33
- Tns .create_app (app_name = "TNS_App" , copy_from = SUT_ROOT_FOLDER + os .path .sep + "template-hello-world-ts" )
34
- Tns .platform_add (platform = "android" , framework_path = ANDROID_RUNTIME_PATH , path = "TNS_App" )
35
-
36
- assert File .extension_exists (
37
- "TNS_App/node_modules/tns-core-modules" , ".d.ts" )
38
-
39
- output = run (TNS_PATH + " install typescript --path TNS_App" )
32
+ output = run (TNS_PATH + " create TNS_App --tsc" )
40
33
assert "nativescript-dev-typescript@" in output
41
34
assert "nativescript-hook@" in output
42
35
36
+ assert File .extension_exists (
37
+ "TNS_App/node_modules/tns-core-modules" , ".d.ts" )
43
38
assert File .exists ("TNS_App/tsconfig.json" )
44
39
assert File .exists ("TNS_App/node_modules/typescript/bin/tsc" )
45
40
assert not Folder .is_empty ("TNS_App/node_modules/nativescript-dev-typescript" )
@@ -50,46 +45,106 @@ def test_001_transpilation_typescript(self):
50
45
assert "devDependencies" in output
51
46
assert "nativescript-dev-typescript" in output
52
47
48
+ Tns .platform_add (platform = "android" , framework_path = ANDROID_RUNTIME_PATH , path = "TNS_App" )
49
+ if CURRENT_OS == OSType .OSX :
50
+ Tns .platform_add (
51
+ platform = "ios" ,
52
+ framework_path = IOS_RUNTIME_SYMLINK_PATH ,
53
+ path = "TNS_App" ,
54
+ symlink = True )
55
+
56
+ def test_101_transpilation_typescript_prepare_debug (self ):
57
+
58
+ # prepare in debug => .ts should go to the platforms folder
53
59
output = Tns .prepare (path = "TNS_App" , platform = "android" )
54
60
assert "Executing before-prepare hook" in output
55
61
assert "Found peer TypeScript" in output
56
62
assert "error" not in output
57
63
58
64
assert File .extension_exists ("TNS_App/app" , ".js" )
65
+ assert File .extension_exists ("TNS_App/app" , ".map" )
59
66
assert File .extension_exists ("TNS_App/app" , ".ts" )
60
67
61
68
assert File .extension_exists (
62
- "TNS_App/platforms/android/src/main/assets/app" , ".js" )
69
+ "TNS_App/platforms/android/src/main/assets/app" , ".js" )
70
+ assert File .extension_exists (
71
+ "TNS_App/platforms/android/src/main/assets/app" , ".map" )
72
+ assert File .extension_exists (
73
+ "TNS_App/platforms/android/src/main/assets/app" , ".ts" )
74
+ assert File .extension_exists (
75
+ "TNS_App/platforms/android/src/main/assets/app/tns_modules/application" , ".js" )
63
76
assert not File .extension_exists (
77
+ "TNS_App/platforms/android/src/main/assets/app/tns_modules/application" , ".ts" )
78
+
79
+ if CURRENT_OS == OSType .OSX :
80
+
81
+ # prepare in debug => .ts should go to the platforms folder
82
+ output = Tns .prepare (platform = "ios" , path = "TNS_App" )
83
+ assert "Executing before-prepare hook" in output
84
+ assert "Found peer TypeScript" in output
85
+ assert "error" not in output
86
+
87
+ assert File .extension_exists ("TNS_App/app" , ".js" )
88
+ assert File .extension_exists ("TNS_App/app" , ".map" )
89
+ assert File .extension_exists ("TNS_App/app" , ".ts" )
90
+
91
+ assert File .extension_exists (
92
+ "TNS_App/platforms/android/src/main/assets/app" , ".js" )
93
+ assert File .extension_exists (
94
+ "TNS_App/platforms/android/src/main/assets/app" , ".map" )
95
+ assert File .extension_exists (
64
96
"TNS_App/platforms/android/src/main/assets/app" , ".ts" )
97
+ assert File .extension_exists (
98
+ "TNS_App/platforms/android/src/main/assets/app/tns_modules/application" , ".js" )
99
+ assert not File .extension_exists (
100
+ "TNS_App/platforms/android/src/main/assets/app/tns_modules/application" , ".ts" )
101
+
102
+ def test_201_transpilation_typescript_prepare_release (self ):
103
+ # prepare in release => .ts should NOT go to the platforms folder
104
+ output = Tns .prepare (path = "TNS_App" , platform = "android" , release = True )
105
+ assert "Executing before-prepare hook" in output
106
+ assert "Found peer TypeScript" in output
107
+ assert "error" not in output
108
+
109
+ assert File .extension_exists ("TNS_App/app" , ".js" )
110
+ assert File .extension_exists ("TNS_App/app" , ".map" )
111
+ assert File .extension_exists ("TNS_App/app" , ".ts" )
112
+
113
+ assert File .extension_exists (
114
+ "TNS_App/platforms/android/src/main/assets/app" , ".js" )
115
+ assert not File .extension_exists (
116
+ "TNS_App/platforms/android/src/main/assets/app" , ".map" )
117
+ assert not File .extension_exists (
118
+ "TNS_App/platforms/android/src/main/assets/app" , ".ts" )
119
+ assert File .extension_exists (
120
+ "TNS_App/platforms/android/src/main/assets/app/tns_modules/application" , ".js" )
65
121
assert not File .extension_exists (
66
- "TNS_App/platforms/android/src/main/assets/app/tns_modules" , ".ts" )
67
- Tns .build (platform = "android" , path = "TNS_App" )
122
+ "TNS_App/platforms/android/src/main/assets/app/tns_modules/application" , ".ts" )
68
123
69
124
if CURRENT_OS == OSType .OSX :
70
- Tns .platform_add (
71
- platform = "ios" ,
72
- framework_path = IOS_RUNTIME_SYMLINK_PATH ,
73
- path = "TNS_App" ,
74
- symlink = True )
75
125
76
- output = Tns .prepare (platform = "ios" , path = "TNS_App" )
126
+ # prepare in release => .ts should NOT go to the platforms folder
127
+ output = Tns .prepare (platform = "ios" , path = "TNS_App" , release = True )
77
128
assert "Executing before-prepare hook" in output
78
129
assert "Found peer TypeScript" in output
79
130
assert "error" not in output
80
131
81
132
assert File .extension_exists ("TNS_App/app" , ".js" )
133
+ assert File .extension_exists ("TNS_App/app" , ".map" )
82
134
assert File .extension_exists ("TNS_App/app" , ".ts" )
83
135
84
136
assert File .extension_exists (
85
- "TNS_App/platforms/ios/TNSApp /app" , ".js" )
137
+ "TNS_App/platforms/android/src/main/assets /app" , ".js" )
86
138
assert not File .extension_exists (
87
- "TNS_App/platforms/ios/TNSApp/app" , ".ts" )
139
+ "TNS_App/platforms/android/src/main/assets/app" , ".map" )
140
+ assert not File .extension_exists (
141
+ "TNS_App/platforms/android/src/main/assets/app" , ".ts" )
142
+ assert File .extension_exists (
143
+ "TNS_App/platforms/android/src/main/assets/app/tns_modules/application" , ".js" )
88
144
assert not File .extension_exists (
89
- "TNS_App/platforms/ios/TNSApp/app/tns_modules" , ".ts" )
90
- Tns .build (platform = "ios" , path = "TNS_App" )
145
+ "TNS_App/platforms/android/src/main/assets/app/tns_modules/application" , ".ts" )
91
146
92
- def test_201_transpilation_after_node_modules_deleted (self ):
147
+ def test_301_transpilation_after_node_modules_deleted (self ):
93
148
Folder .cleanup ("TNS_App/node_modules" )
94
149
# Next line is because prepare does not work if you npm install packages with relative path before that
95
150
Folder .navigate_to ("TNS_App" )
0 commit comments