Skip to content

Commit 2d0dbfd

Browse files
vchimevvchimev
vchimev
authored and
vchimev
committed
Update transpilers tests
1 parent d7d5db7 commit 2d0dbfd

File tree

2 files changed

+86
-28
lines changed

2 files changed

+86
-28
lines changed

core/tns/tns.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,6 @@ def create_app(app_name, path=None, app_id=None, copy_from=None, template=None,
5050
command += " --log trace"
5151
output = run(command)
5252

53-
if assert_success:
54-
assert "Project {0} was successfully created".format(app_name.replace("\"", "")) in output
55-
5653
if update_modules:
5754
if path is not None:
5855
app_name = path + app_name
@@ -66,6 +63,9 @@ def create_app(app_name, path=None, app_id=None, copy_from=None, template=None,
6663
npm_out4 = run("npm install " + widgets_path + " --save")
6764
Folder.navigate_to(TEST_RUN_HOME, relative_from__current_folder=False)
6865
output = output + npm_out1 + npm_out2 + npm_out3 + npm_out4
66+
67+
if assert_success:
68+
assert "Project {0} was successfully created".format(app_name.replace("\"", "")) in output
6969
return output
7070

7171
@staticmethod
@@ -97,7 +97,7 @@ def platform_add(platform=None, framework_path=None, path=None, symlink=False, l
9797
return output
9898

9999
@staticmethod
100-
def prepare(platform=None, path=None, assert_success=True, log_trace=False):
100+
def prepare(platform=None, path=None, assert_success=True, log_trace=False, release=False):
101101
"""
102102
Prepare target platform.
103103
"""
@@ -112,6 +112,9 @@ def prepare(platform=None, path=None, assert_success=True, log_trace=False):
112112

113113
if log_trace:
114114
command += " --log trace"
115+
116+
if release is True:
117+
command += " --release"
115118
output = run(command)
116119

117120
if assert_success:

tests/transpilers/typescript.py

Lines changed: 79 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
from core.osutils.command import run
55
from core.osutils.file import File
66
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
99
from core.tns.tns import Tns
1010

1111

@@ -28,18 +28,13 @@ def tearDown(self):
2828
def tearDownClass(cls):
2929
Folder.cleanup('TNS_App')
3030

31-
unittest.skip("")
3231
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")
4033
assert "nativescript-dev-typescript@" in output
4134
assert "nativescript-hook@" in output
4235

36+
assert File.extension_exists(
37+
"TNS_App/node_modules/tns-core-modules", ".d.ts")
4338
assert File.exists("TNS_App/tsconfig.json")
4439
assert File.exists("TNS_App/node_modules/typescript/bin/tsc")
4540
assert not Folder.is_empty("TNS_App/node_modules/nativescript-dev-typescript")
@@ -50,46 +45,106 @@ def test_001_transpilation_typescript(self):
5045
assert "devDependencies" in output
5146
assert "nativescript-dev-typescript" in output
5247

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
5359
output = Tns.prepare(path="TNS_App", platform="android")
5460
assert "Executing before-prepare hook" in output
5561
assert "Found peer TypeScript" in output
5662
assert "error" not in output
5763

5864
assert File.extension_exists("TNS_App/app", ".js")
65+
assert File.extension_exists("TNS_App/app", ".map")
5966
assert File.extension_exists("TNS_App/app", ".ts")
6067

6168
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")
6376
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(
6496
"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")
65121
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")
68123

69124
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)
75125

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)
77128
assert "Executing before-prepare hook" in output
78129
assert "Found peer TypeScript" in output
79130
assert "error" not in output
80131

81132
assert File.extension_exists("TNS_App/app", ".js")
133+
assert File.extension_exists("TNS_App/app", ".map")
82134
assert File.extension_exists("TNS_App/app", ".ts")
83135

84136
assert File.extension_exists(
85-
"TNS_App/platforms/ios/TNSApp/app", ".js")
137+
"TNS_App/platforms/android/src/main/assets/app", ".js")
86138
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")
88144
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")
91146

92-
def test_201_transpilation_after_node_modules_deleted(self):
147+
def test_301_transpilation_after_node_modules_deleted(self):
93148
Folder.cleanup("TNS_App/node_modules")
94149
# Next line is because prepare does not work if you npm install packages with relative path before that
95150
Folder.navigate_to("TNS_App")

0 commit comments

Comments
 (0)