// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.json;

import org.jetbrains.annotations.NotNull;

public class JsonEnterHandlingTest extends JsonTestCase {
  private void doTest(@NotNull final String before, @NotNull final String expected) {
    doTest(before, expected, "json");
  }

  private void doTest(@NotNull final String before, @NotNull final String expected, @NotNull final String extension) {
    myFixture.configureByText("test." + extension, before);
    myFixture.type('\n');
    myFixture.checkResult(expected);
  }

  public void testEnterAfterProperty() {
    doTest("{\"a\": true<caret>}", "{\"a\": true,\n}");
  }

  public void testEnterMidProperty() {
    doTest("{\"a\": tr<caret>ue}", "{\"a\": true,\n}");
  }

  public void testEnterMidObjectNoFollowing() {
    doTest("{\"a\": {<caret>}", "{\"a\": {\n  \n}\n}");
  }

  public void testEnterMidObjectWithFollowing() {
    doTest("{\"a\": {<caret>} \"b\": 5}", "{\"a\": {\n  \n}, \"b\": 5}");
  }

  public void testEnterAfterObject() {
    doTest("{\"a\": {}<caret>}", "{\"a\": {},\n}");
  }
}

@@ -910,32 +910,33 @@
 %5C%22a%5C%22: %7B%3Ccaret%3E%7D
+%7D
 %22, %22%7B%5C%22a%5C%22: %7B%5Cn 
@@ -939,18 +939,16 @@
 %7B%5Cn  %5Cn%7D
-%5Cn
 %7D%22);%0A  %7D

fix JsonEnterHandlingTest.testEnterMidObjectNoFollowing