Move remaining JSON completion tests from JavaScript to platform

This commit is contained in:
Mikhail Golubev
2014-09-11 16:36:54 +04:00
parent f7dac28085
commit 93abb59764
6 changed files with 26 additions and 14 deletions

View File

@@ -1,20 +1,32 @@
package com.intellij.json;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.util.ArrayUtil;
/**
* @author Mikhail Golubev
*/
public class JsonCompletionTest extends JsonTestCase {
private static final String[] KEYWORDS = new String[]{"true", "false", "null"};
private static final String[] ALL_KEYWORDS = new String[]{"true", "false", "null"};
private static final String[] NOTHING = ArrayUtil.EMPTY_STRING_ARRAY;
private void doTest(String... variants) {
myFixture.testCompletionVariants("completion/" + getTestName(false) + ".json", variants);
}
private void doTestSingleVariant() {
myFixture.configureByFile("completion/" + getTestName(false) + ".json");
final LookupElement[] variants = myFixture.completeBasic();
assertNull(variants);
myFixture.checkResultByFile("completion/" + getTestName(false) + "_after.json" );
}
public void testInsideArrayElement1() throws Exception {
doTest(KEYWORDS);
doTest(ALL_KEYWORDS);
}
public void testInsideArrayElement2() throws Exception {
doTest(KEYWORDS);
doTest(ALL_KEYWORDS);
}
public void testInsidePropertyKey1() throws Exception {
@@ -26,17 +38,16 @@ public class JsonCompletionTest extends JsonTestCase {
}
public void testInsidePropertyValue() throws Exception {
doTest(KEYWORDS);
doTest(ALL_KEYWORDS);
}
private void doTest(String... variants) {
myFixture.testCompletionVariants("completion/" + getTestName(false) + ".json", variants);
// Moved from JavaScript
public void testKeywords() {
doTestSingleVariant();
}
public void testWithPrefix() {
// Before artificial reference expressions were added to grammar, lack of identifier-like tokens
// might lead to problems with keyword completion.
myFixture.configureByFile("completion/" + getTestName(false) + ".json");
assertNull(myFixture.completeBasic());
public void testKeywords_2() {
doTestSingleVariant();
}
}

View File

@@ -0,0 +1 @@
[nu<caret>]

View File

@@ -0,0 +1 @@
{aaa:nu<caret>}

View File

@@ -0,0 +1 @@
{aaa:null<caret>}

View File

@@ -0,0 +1 @@
[null<caret>]

View File

@@ -1,3 +0,0 @@
{
"foo": nu<caret>
}