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 {
|
protected void doTest(@NotNull String beforeFileName) throws Exception {
|
||||||
boolean isWithRuntime = beforeFileName.endsWith("Runtime.kt");
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (isWithRuntime) {
|
configureRuntimeIfNeeded(beforeFileName);
|
||||||
ConfigLibraryUtil.configureKotlinRuntime(getModule(), getFullJavaJDK());
|
|
||||||
}
|
|
||||||
|
|
||||||
enableInspections(beforeFileName);
|
enableInspections(beforeFileName);
|
||||||
|
|
||||||
@@ -81,9 +77,25 @@ public abstract class AbstractQuickFixTest extends KotlinLightQuickFixTestCase {
|
|||||||
checkForUnexpectedErrors();
|
checkForUnexpectedErrors();
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
if (isWithRuntime) {
|
unConfigureRuntimeIfNeeded(beforeFileName);
|
||||||
ConfigLibraryUtil.unConfigureKotlinRuntime(getModule(), getProjectJDK());
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
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")
|
@TestMetadata("beforeLibraryPropertyRuntime.kt")
|
||||||
public void testLibraryPropertyRuntime() throws Exception {
|
public void testLibraryPropertyRuntime() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/autoImports/beforeLibraryPropertyRuntime.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/autoImports/beforeLibraryPropertyRuntime.kt");
|
||||||
doTest(fileName);
|
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")
|
@TestMetadata("beforeLibraryTopLevelFunctionImportRuntime.kt")
|
||||||
public void testLibraryTopLevelFunctionImportRuntime() throws Exception {
|
public void testLibraryTopLevelFunctionImportRuntime() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/autoImports/beforeLibraryTopLevelFunctionImportRuntime.kt");
|
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);
|
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) {
|
public static void configureLibrary(Module module, Sdk sdk, NewLibraryEditor libraryEditor) {
|
||||||
configureSdk(module, sdk);
|
configureSdk(module, sdk);
|
||||||
addLibrary(libraryEditor, module);
|
addLibrary(libraryEditor, module);
|
||||||
|
|||||||
Reference in New Issue
Block a user