JS: add tests for quickfix: autoimport for Kotlin/Javascript projects
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
// "Import" "true"
|
||||
// ERROR: Please specify constructor invocation; classifier 'HTMLStyleElement' does not have a companion object
|
||||
|
||||
package test
|
||||
|
||||
import kotlin.js.dom.html.HTMLStyleElement
|
||||
|
||||
fun foo() {
|
||||
HTMLStyleElement
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// "Import" "true"
|
||||
|
||||
package test
|
||||
|
||||
import kotlin.js.dom.html5.localStorage
|
||||
|
||||
fun foo() {
|
||||
localStorage
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// "Import" "true"
|
||||
package some
|
||||
|
||||
import jquery.jq
|
||||
|
||||
fun testFun() {
|
||||
jq()
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// "Import" "true"
|
||||
// ERROR: Please specify constructor invocation; classifier 'HTMLStyleElement' does not have a companion object
|
||||
|
||||
package test
|
||||
|
||||
fun foo() {
|
||||
<caret>HTMLStyleElement
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// "Import" "true"
|
||||
|
||||
package test
|
||||
|
||||
fun foo() {
|
||||
<caret>localStorage
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// "Import" "true"
|
||||
package some
|
||||
|
||||
fun testFun() {
|
||||
<caret>jq()
|
||||
}
|
||||
@@ -67,12 +67,8 @@ public abstract class AbstractQuickFixTest extends KotlinLightQuickFixTestCase {
|
||||
}
|
||||
|
||||
protected void doTest(@NotNull String beforeFileName) throws Exception {
|
||||
boolean isWithRuntime = beforeFileName.endsWith("Runtime.kt");
|
||||
|
||||
try {
|
||||
if (isWithRuntime) {
|
||||
ConfigLibraryUtil.configureKotlinRuntime(getModule(), getFullJavaJDK());
|
||||
}
|
||||
configureRuntimeIfNeeded(beforeFileName);
|
||||
|
||||
enableInspections(beforeFileName);
|
||||
|
||||
@@ -81,9 +77,25 @@ public abstract class AbstractQuickFixTest extends KotlinLightQuickFixTestCase {
|
||||
checkForUnexpectedErrors();
|
||||
}
|
||||
finally {
|
||||
if (isWithRuntime) {
|
||||
ConfigLibraryUtil.unConfigureKotlinRuntime(getModule(), getProjectJDK());
|
||||
}
|
||||
unConfigureRuntimeIfNeeded(beforeFileName);
|
||||
}
|
||||
}
|
||||
|
||||
private static void configureRuntimeIfNeeded(@NotNull String beforeFileName) {
|
||||
if (beforeFileName.endsWith("JsRuntime.kt")) {
|
||||
ConfigLibraryUtil.configureKotlinJsRuntime(getModule(), getFullJavaJDK());
|
||||
}
|
||||
else if (beforeFileName.endsWith("Runtime.kt")) {
|
||||
ConfigLibraryUtil.configureKotlinRuntime(getModule(), getFullJavaJDK());
|
||||
}
|
||||
}
|
||||
|
||||
private void unConfigureRuntimeIfNeeded(@NotNull String beforeFileName) {
|
||||
if (beforeFileName.endsWith("JsRuntime.kt")) {
|
||||
ConfigLibraryUtil.unConfigureKotlinJsRuntime(getModule(), getProjectJDK());
|
||||
}
|
||||
else if (beforeFileName.endsWith("Runtime.kt")) {
|
||||
ConfigLibraryUtil.unConfigureKotlinRuntime(getModule(), getProjectJDK());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -395,12 +395,30 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("beforeLibraryClassJsRuntime.kt")
|
||||
public void testLibraryClassJsRuntime() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/autoImports/beforeLibraryClassJsRuntime.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("beforeLibraryPropertyJsRuntime.kt")
|
||||
public void testLibraryPropertyJsRuntime() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/autoImports/beforeLibraryPropertyJsRuntime.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("beforeLibraryPropertyRuntime.kt")
|
||||
public void testLibraryPropertyRuntime() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/autoImports/beforeLibraryPropertyRuntime.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("beforeLibraryTopLevelFunctionImportJsRuntime.kt")
|
||||
public void testLibraryTopLevelFunctionImportJsRuntime() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/autoImports/beforeLibraryTopLevelFunctionImportJsRuntime.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("beforeLibraryTopLevelFunctionImportRuntime.kt")
|
||||
public void testLibraryTopLevelFunctionImportRuntime() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/autoImports/beforeLibraryTopLevelFunctionImportRuntime.kt");
|
||||
|
||||
@@ -60,6 +60,10 @@ public class ConfigLibraryUtil {
|
||||
unConfigureLibrary(module, sdk, DEFAULT_JAVA_RUNTIME_LIB_NAME);
|
||||
}
|
||||
|
||||
public static void unConfigureKotlinJsRuntime(Module module, Sdk sdk) {
|
||||
unConfigureLibrary(module, sdk, DEFAULT_KOTLIN_JS_STDLIB_NAME);
|
||||
}
|
||||
|
||||
public static void configureLibrary(Module module, Sdk sdk, NewLibraryEditor libraryEditor) {
|
||||
configureSdk(module, sdk);
|
||||
addLibrary(libraryEditor, module);
|
||||
|
||||
Reference in New Issue
Block a user