Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added tests of formatter config where only default was applied.
  • Loading branch information
fvgh committed Aug 5, 2018
commit d5a77fbed8ffead7ddd92d17c6984c8cb042daaa
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,22 @@ public class EclipseCssFormatterStepImplTest {

private final static String ILLEGAL_CHAR = Character.toString((char) 254);
private final static String UNFORMATTED = " body {a: v; b: v;}\n".replaceAll("\n", LINE_DELIMITER);
private final static String FORMATTED = "BODY {\n\ta: v;\n\tb: v;\n}".replaceAll("\n", LINE_DELIMITER);
private final static String FORMATTED = "BODY {\n a: v;\n b: v;\n}".replaceAll("\n", LINE_DELIMITER);
private final static String PRE_CODE_UNFORMATTED = "/**<pre>\"Hello\"</pre>*/\n".replaceAll("\n", LINE_DELIMITER);

private EclipseCssFormatterStepImpl formatter;

@Before
public void initialize() throws Exception {
//The instantiation can be repeated for each step, but only with the same configuration
/*
* The instantiation can be repeated for each step, but only with the same configuration
* All formatter configuration is stored in
* org.eclipse.core.runtime/.settings/org.eclipse.wst.css.core.prefs.
* So a simple test of one configuration item change is considered sufficient.
*/
Properties properties = new Properties();
properties.put(INDENTATION_CHAR, TAB); //Done be formatter
properties.put(INDENTATION_SIZE, "3"); //Default is 1
properties.put(INDENTATION_CHAR, SPACE); //Default is TAB
properties.put(CLEANUP_CASE_SELECTOR, Integer.toString(UPPER)); //Done by cleanup
formatter = new EclipseCssFormatterStepImpl(properties);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,27 @@
public class EclipseJsonFormatterStepImplTest {
private final static String ILLEGAL_CHAR = Character.toString((char) 254);
private final static String UNFORMATTED = "{\n \"x\": { \"a\" : \"v\",\"properties\" : \"v\" }}".replaceAll("\n", LINE_DELIMITER);
private final static String FORMATTED = "{\n\t\"x\": {\n\t\t\"a\": \"v\",\n\t\t\"properties\": \"v\"\n\t}\n}".replaceAll("\n", LINE_DELIMITER);
private final static String FORMATTED = "{\n \"x\": {\n \"a\": \"v\",\n \"properties\": \"v\"\n }\n}".replaceAll("\n", LINE_DELIMITER);

private static EclipseJsonFormatterStepImpl formatter;

@Before
public void initialize() throws Exception {
//The instantiation can be repeated for each step, but only with the same configuration
/*
* The instantiation can be repeated for each step, but only with the same configuration
* All formatter configuration is stored in
* org.eclipse.core.runtime/.settings/org.eclipse.wst.json.core.prefs.
* So a simple test of one configuration item change is considered sufficient.
*/
Properties properties = new Properties();
properties.put(INDENTATION_CHAR, TAB); //Done by formatter
properties.put(INDENTATION_SIZE, "3"); //Default is 1
properties.put(INDENTATION_CHAR, SPACE); //Default is TAB
properties.put(CASE_PROPERTY_NAME, Integer.toString(UPPER)); //Dead code, ignored
formatter = new EclipseJsonFormatterStepImpl(properties);
}

@Test
public void defaultFormat() throws Exception {
public void format() throws Exception {
String output = formatter.format(UNFORMATTED);
assertEquals("Unexpected formatting with default preferences.",
FORMATTED, output);
Expand Down