Search in sources :

Example 11 with Arguments

use of com.squarespace.template.Arguments in project template-compiler by Squarespace.

the class CoreFormattersTest method testMod.

@Test
public void testMod() throws CodeException {
    CodeMaker mk = maker();
    Arguments args = mk.args(" 3");
    assertFormatter(MOD, args, "4", "1");
    assertFormatter(MOD, args, "5", "2");
    assertFormatter(MOD, args, "6", "0");
    // Bad modulus defaults to 2
    args = mk.args(" abc");
    assertFormatter(MOD, args, "5", "1");
    // Bad value defaults to 0
    assertFormatter(MOD, args, "\"abc\"", "0");
}
Also used : Arguments(com.squarespace.template.Arguments) CodeMaker(com.squarespace.template.CodeMaker) Test(org.testng.annotations.Test)

Example 12 with Arguments

use of com.squarespace.template.Arguments in project template-compiler by Squarespace.

the class CoreFormattersTest method testRound.

@Test
public void testRound() throws CodeException {
    CodeMaker mk = maker();
    Arguments args = mk.args("");
    assertFormatter(ROUND, args, "1.44", "1");
    assertFormatter(ROUND, args, "1.6", "2");
}
Also used : Arguments(com.squarespace.template.Arguments) CodeMaker(com.squarespace.template.CodeMaker) Test(org.testng.annotations.Test)

Example 13 with Arguments

use of com.squarespace.template.Arguments in project template-compiler by Squarespace.

the class CoreFormattersTest method testOutput.

@Test
public void testOutput() throws CodeException {
    CodeMaker mk = maker();
    Arguments args = mk.args(":1:2:3");
    assertFormatter(OUTPUT, args, "{}", "1 2 3");
}
Also used : Arguments(com.squarespace.template.Arguments) CodeMaker(com.squarespace.template.CodeMaker) Test(org.testng.annotations.Test)

Example 14 with Arguments

use of com.squarespace.template.Arguments in project template-compiler by Squarespace.

the class ContentFormattersTest method testSquarespaceThumbnail.

@Test
public void testSquarespaceThumbnail() throws CodeException {
    CodeMaker mk = maker();
    Arguments args = mk.args(" 50");
    String json = "\"100x200\"";
    assertFormatter(SQSP_THUMB_FOR_WIDTH, args, json, "100w");
    assertFormatter(SQSP_THUMB_FOR_HEIGHT, args, json, "100w");
    args = mk.args(" 600");
    json = "\"1200x2400\"";
    assertFormatter(SQSP_THUMB_FOR_WIDTH, args, json, "750w");
    assertFormatter(SQSP_THUMB_FOR_HEIGHT, args, json, "300w");
}
Also used : Arguments(com.squarespace.template.Arguments) CodeMaker(com.squarespace.template.CodeMaker) Test(org.testng.annotations.Test)

Aggregations

Arguments (com.squarespace.template.Arguments)14 CodeMaker (com.squarespace.template.CodeMaker)10 Test (org.testng.annotations.Test)10 Context (com.squarespace.template.Context)5 Variables (com.squarespace.template.Variables)3 ArgumentsException (com.squarespace.template.ArgumentsException)1 CodeBuilder (com.squarespace.template.CodeBuilder)1 Instruction (com.squarespace.template.Instruction)1 StringView (com.squarespace.template.StringView)1 Locale (java.util.Locale)1