Search in sources :

Example 1 with JsTestElementPath

use of com.intellij.javascript.testFramework.JsTestElementPath in project intellij-plugins by JetBrains.

the class KarmaRunConfigurationProducer method setupAsSuiteOrTest.

@Nullable
private static Pair<KarmaRunSettings, PsiElement> setupAsSuiteOrTest(@NotNull JSFile file, @NotNull VirtualFile virtualFile, @NotNull PsiElement element, @NotNull KarmaRunSettings templateSettings) {
    TextRange textRange = element.getTextRange();
    if (textRange == null || !file.isTestFile()) {
        return null;
    }
    JasmineFileStructure jasmineStructure = JasmineFileStructureBuilder.getInstance().fetchCachedTestFileStructure(file);
    JsTestElementPath path = jasmineStructure.findTestElementPath(textRange);
    if (path != null) {
        templateSettings = guessConfigFileIfNeeded(templateSettings, virtualFile, element.getProject());
        KarmaRunSettings.Builder builder = templateSettings.toBuilder();
        String testName = path.getTestName();
        if (testName == null) {
            builder.setScopeKind(KarmaScopeKind.SUITE);
            builder.setTestNames(path.getSuiteNames());
        } else {
            builder.setScopeKind(KarmaScopeKind.TEST);
            builder.setTestNames(path.getAllNames());
        }
        return Pair.create(builder.build(), path.getTestElement());
    }
    return null;
}
Also used : TextRange(com.intellij.openapi.util.TextRange) JsTestElementPath(com.intellij.javascript.testFramework.JsTestElementPath) JasmineFileStructure(com.intellij.javascript.testFramework.jasmine.JasmineFileStructure) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

JsTestElementPath (com.intellij.javascript.testFramework.JsTestElementPath)1 JasmineFileStructure (com.intellij.javascript.testFramework.jasmine.JasmineFileStructure)1 TextRange (com.intellij.openapi.util.TextRange)1 Nullable (org.jetbrains.annotations.Nullable)1