Skip to content

Commit b56029f

Browse files
updated tests
1 parent b32a8ac commit b56029f

16 files changed

+2819
-43
lines changed

main.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from .src.libs import *
77
from .src.commands import *
88
from .src.listeners import *
9-
from .tests import *
109

1110
keymaps = util.open_json(os.path.join(PACKAGE_PATH, 'Default.sublime-keymap'))
1211
for keymap in keymaps:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
[{"id": "tools", "caption": "Tools", "children": [{"id": "npm_scripts", "caption": "Npm/Yarn Scripts", "children": []}]}]
1+
[{"id": "tools", "children": [{"id": "npm_scripts", "children": [], "caption": "Npm/Yarn Scripts"}], "caption": "Tools"}]

tests/__init__.py

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/plugin_ready.py

Lines changed: 0 additions & 29 deletions
This file was deleted.

tests/test_completions.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import sublime
2-
import time
2+
import time, os
33
from unittesting import DeferrableTestCase
44
JavaScriptEnhancements = __import__('JavaScript Enhancements')
55
flow_ide_clients = JavaScriptEnhancements.src.libs.flow_ide_clients
66
JavascriptEnhancementsStartFlowIDEServerEventListener = JavaScriptEnhancements.src.libs.JavascriptEnhancementsStartFlowIDEServerEventListener
7+
PACKAGE_PATH = JavaScriptEnhancements.src.libs.global_vars.PACKAGE_PATH
8+
9+
def plugin_ready():
10+
return os.path.exists(os.path.join(PACKAGE_PATH, "node_modules", ".bin"))
711

812
timeout = 30
913

@@ -22,12 +26,15 @@ def tearDown(self):
2226
self.view.window().run_command("close_file")
2327

2428
def test_completions(self):
29+
30+
start_time = time.time()
2531

26-
for x in JavaScriptEnhancements.tests.wait_plugin_ready():
27-
if not x:
28-
yield 100
32+
while not plugin_ready():
33+
if time.time() - start_time <= timeout:
34+
yield 200
2935
else:
30-
break
36+
raise TimeoutError("plugin is not ready in " + str(timeout) + " seconds")
37+
3138
self.view.run_command("insert", {"characters": "\ndocument."})
3239

3340
JavascriptEnhancementsStartFlowIDEServerEventListener().start_server(self.view)
@@ -46,7 +53,6 @@ def test_completions(self):
4653

4754
else:
4855
raise TimeoutError("auto_complete popup doesn't show up in " + str(timeout) + " seconds")
49-
break
5056

5157
self.view.run_command("commit_completion")
5258

tests/test_project.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from unittesting import DeferrableTestCase
55
JavaScriptEnhancements = __import__('JavaScript Enhancements')
66
util = JavaScriptEnhancements.src.libs.util
7+
PACKAGE_PATH = JavaScriptEnhancements.src.libs.global_vars.PACKAGE_PATH
78

89
project_path = os.path.join(os.path.expanduser("~"), "javascript_enhancements_project_test")
910
project_settings = {
@@ -15,20 +16,36 @@
1516
'bookmarks': []
1617
}
1718

19+
def plugin_ready():
20+
return os.path.exists(os.path.join(PACKAGE_PATH, "node_modules", ".bin"))
21+
22+
timeout = 30
23+
1824
class TestProject(DeferrableTestCase):
1925

2026
def setUp(self):
21-
self.window = sublime.active_window()
27+
sublime.run_command('new_window')
28+
self.view = sublime.active_window().new_file()
29+
self.window = self.view.window()
2230
if os.path.isdir(project_path):
2331
shutil.rmtree(project_path)
2432

2533
def tearDown(self):
2634
global project_path
2735
sublime.active_window().run_command("close")
36+
sublime.active_window().run_command("close")
2837
if os.path.isdir(project_path):
2938
shutil.rmtree(project_path)
3039

3140
def test_project(self):
41+
start_time = time.time()
42+
43+
while not plugin_ready():
44+
if time.time() - start_time <= timeout:
45+
yield 200
46+
else:
47+
raise TimeoutError("plugin is not ready in " + str(timeout) + " seconds")
48+
3249
self.window.run_command("javascript_enhancements_create_new_project")
3350
yield 1000
3451
self.window.run_command("insert", {"characters": "empty"})

0 commit comments

Comments
 (0)