Skip to content

Commit

Permalink
WIP: Add commands plugin with unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ratijas committed Nov 19, 2023
1 parent a73ae7d commit a489743
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/commands.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Commands Tests

on:
push:
paths:
- '.github/workflows/commands.yml'
- '**.py'
pull_request:
paths:
- '.github/workflows/commands.yml'
- '**.py'

jobs:
run-tests:
strategy:
fail-fast: false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: SublimeText/UnitTesting/actions/setup@v1
with:
sublime-text-version: 4
- uses: SublimeText/UnitTesting/actions/run-tests@v1
with:
coverage: true
- uses: codecov/codecov-action@v3
Empty file added Support/QMLCommands.py
Empty file.
30 changes: 30 additions & 0 deletions Support/tests/test_commands.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import sublime
import sys
from unittest import TestCase

class TestConvertBetweenPropertyAndSignalHandler(TestCase):
def setUp(self):
self.view = sublime.active_window().new_file()
# make sure we have a window to work with
s = sublime.load_settings("Preferences.sublime-settings")
s.set("close_windows_when_empty", False)

def tearDown(self):
if self.view:
self.view.set_scratch(True)
w = self.view.window()
if w:
w.focus_view(self.view)
w.run_command("close_file")

def setText(self, string):
self.view.run_command("insert", {"characters": string})

def getRow(self, row):
return self.view.substr(self.view.line(self.view.text_point(row, 0)))

def test_hello_world(self):
self.setText("new ")
self.view.run_command("hello_world")
first_row = self.getRow(0)
self.assertEqual(first_row, "new hello world")
3 changes: 3 additions & 0 deletions unittesting.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"tests_dir": "Support/tests"
}

0 comments on commit a489743

Please sign in to comment.