-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtest_ng_generate_shared.py
76 lines (64 loc) · 3.88 KB
/
test_ng_generate_shared.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
"""
Tests for `ng g` in context of shared application.
"""
import unittest
from core.base_test.tns_test import TnsTest
from core.settings import Settings
from core.utils.file_utils import Folder
from products.angular.ng import NG, NS_SCHEMATICS
from products.nativescript.tns_assert import TnsAssert
from products.nativescript.tns_paths import TnsPaths
# noinspection PyMethodMayBeStatic
class NGGenerateSharedTests(TnsTest):
app_name = Settings.AppName.DEFAULT
app_path = TnsPaths.get_app_path(app_name=app_name)
@classmethod
def setUpClass(cls):
TnsTest.setUpClass()
NG.kill()
Folder.clean(cls.app_path)
# Create app
NG.new(collection=NS_SCHEMATICS, project=cls.app_name, shared=True)
TnsAssert.created(app_name=cls.app_name, app_data=None)
def setUp(self):
TnsTest.setUpClass()
NG.kill()
def tearDown(self):
NG.kill()
TnsTest.tearDown(self)
def test_001_generate_component(self):
result = NG.exec_command(command='g c component-test', cwd=self.app_path)
assert 'CREATE src/app/component-test/component-test.component.html' in result.output
assert 'CREATE src/app/component-test/component-test.component.ts' in result.output
assert 'CREATE src/app/component-test/component-test.component.css' in result.output
assert 'CREATE src/app/component-test/component-test.component.tns.css' in result.output
assert 'CREATE src/app/component-test/component-test.component.tns.html' in result.output
assert 'UPDATE src/app/app.module.ts' in result.output
assert 'UPDATE src/app/app.module.tns.ts' in result.output
def test_002_generate_module(self):
result = NG.exec_command(command='g m module-test', cwd=self.app_path)
assert 'CREATE src/app/module-test/module-test.module.ts' in result.output
assert 'CREATE src/app/module-test/module-test.module.tns.ts' in result.output
assert 'CREATE src/app/module-test/module-test.common.ts' in result.output
def test_003_generate_component_in_existing_modules(self):
result = NG.exec_command(command='g m module-test2', cwd=self.app_path)
assert 'CREATE src/app/module-test2/module-test2.module.ts' in result.output
assert 'CREATE src/app/module-test2/module-test2.module.tns.ts' in result.output
assert 'CREATE src/app/module-test2/module-test2.common.ts' in result.output
result = NG.exec_command(command='g c module-test2/component-name', cwd=self.app_path)
assert 'CREATE src/app/module-test2/component-name/component-name.component.html' in result.output
assert 'CREATE src/app/module-test2/component-name/component-name.component.ts' in result.output
assert 'CREATE src/app/module-test2/component-name/component-name.component.css' in result.output
assert 'CREATE src/app/module-test2/component-name/component-name.component.tns.css' in result.output
assert 'CREATE src/app/module-test2/component-name/component-name.component.tns.html' in result.output
assert 'UPDATE src/app/module-test2/module-test2.module.ts' in result.output
assert 'UPDATE src/app/module-test2/module-test2.module.tns.ts' in result.output
@unittest.skip('Skip because of https://github.com/NativeScript/nativescript-schematics/issues/194')
def test_004_generate_master_detail(self):
result = NG.exec_command(command='g master-detail --master=dogs --detail=dog', cwd=self.app_path)
assert 'CREATE src/app/dogs/dog-detail/dog-detail.component.html' in result.output
assert 'CREATE src/app/dogs/dog-detail/dog-detail.component.tns.html' in result.output
assert 'CREATE src/app/dogs/dogs/dogs.component.html' in result.output
assert 'CREATE src/app/dogs/dogs/dogs.component.tns.html' in result.output
assert 'data.service.ts' in result.output
assert 'dogs.module.ts' in result.output