insertUTestCase. Close #60

This commit is contained in:
Yvon
2022-06-18 21:05:49 +03:00
parent 6e312755d1
commit f3de20d696

View File

@@ -49,4 +49,25 @@ class ${className} {}
"${base}.${correspondingExt}"))
(function showCorrespondingFile [&opt _]
(showTextDocument (Uri.file (correspondingFile .fileName .document activeTextEditor))))
(showTextDocument (Uri.file (correspondingFile .fileName .document activeTextEditor))))
(function insertUTestCase [&opt _]
(awaitLet [testName (inputBox)]
(let [testName
"$(.toUpperCase (testName.substr 0 1))$(testName.substr 1)"]
(awaitLet [_ (insert
"function test${testName}() {
_test${testName}();
}
")
_ (showTextDocument (Uri.file (correspondingFile .fileName .document activeTextEditor)))]
(let [pos (activeTextEditor.document.positionAt .length (activeTextEditor.document.getText))]
(awaitLet [_ (insertAt pos
"
(function _test${testName} []
(Assert.pass))
")]
(let [endPos (activeTextEditor.document.positionAt .length (activeTextEditor.document.getText))]
(activeTextEditor.revealRange (new Range pos endPos))
(set activeTextEditor.selection (new Selection pos endPos)))))))))