assertEquals("", r.renderDataTable(dataTable, true, false));
assertEquals("", r.renderDataTable(dataTable, true, true));
}
public void testAppendCellJson() {
TableCell dateCell = new TableCell(new DateValue(2009, 1, 12));
TableCell timeofdayCell = new TableCell(new TimeOfDayValue(12, 13, 14, 15));
TableCell datetimeCell = new TableCell(new DateTimeValue(2009, 1, 12, 12, 13, 14, 15));
TableCell booleanCell = new TableCell(true);
TableCell numberCell = new TableCell(12.3);
TableCell textCell = new TableCell("aba");
JsonRenderer r = new JsonpRenderer();
assertEquals("{\"v\":new Date(2009,1,12)}",
r.appendCellJson(dateCell, new StringBuilder(),
true, false).toString());
assertEquals("{\"v\":[12,13,14,15]}",
r.appendCellJson(timeofdayCell, new StringBuilder(),
true, false).toString());
assertEquals("{\"v\":new Date(2009,1,12,12,13,14)}", //no milliseconds passed
r.appendCellJson(datetimeCell, new StringBuilder(),
true, false).toString());
assertEquals("{\"v\":true}",
r.appendCellJson(booleanCell, new StringBuilder(),
true, false).toString());
assertEquals("{\"v\":12.3}",
r.appendCellJson(numberCell, new StringBuilder(),
true, false).toString());
assertEquals("{\"v\":\"aba\"}",
r.appendCellJson(textCell, new StringBuilder(),
true, false).toString());
// No formatting still stays the same when there is no formatted value
assertEquals("{\"v\":12.3}",
r.appendCellJson(numberCell, new StringBuilder(),
false, false).toString());
dateCell = new TableCell(new DateValue(2009, 1, 12), "2009-2-12");
// With formatting
assertEquals("{\"v\":new Date(2009,1,12),\"f\":\"2009-2-12\"}",
r.appendCellJson(dateCell, new StringBuilder(),
true, false).toString());