use of com.github.jknack.handlebars.Options in project hippo by NHS-digital-website.
the class IfRequiredHelperTest method rendersInverseBlock_whenParentModelIsNotSchema.
@Test
public void rendersInverseBlock_whenParentModelIsNotSchema() throws IOException {
// given
final Object parentModelNotSchema = new Object();
final Schema<?> currentSchemaModel = new ObjectSchema();
final Options options = OptionsStub.with(buffer, currentSchemaModel, parentModelNotSchema);
// when
final Options.Buffer actualBuffer = ifRequiredHelper.apply(currentSchemaModel, options);
// then
assertThat("Returns buffer provided by Handlebars through Options.", actualBuffer, sameInstance(actualBuffer));
then(actualBuffer).should().append(TEMPLATE_CONTENT_FROM_INVERSE_BLOCK);
}
use of com.github.jknack.handlebars.Options in project hippo by NHS-digital-website.
the class TypeAnyHelperTest method rendersMainBlock_forJsonObject.
@Test
public void rendersMainBlock_forJsonObject() throws IOException {
// given
final ObjectNode jsonObject = new ObjectNode(jsonFactory);
// when
final Options.Buffer actualBuffer = helper.apply(jsonObject, options);
// then
then(actualBuffer).should().append(OptionsStub.TEMPLATE_CONTENT_FROM_MAIN_BLOCK);
assertThat("Returns buffer provided by Handlebars through Options.", buffer, sameInstance(actualBuffer));
}
use of com.github.jknack.handlebars.Options in project hippo by NHS-digital-website.
the class TypeAnyHelperTest method rendersInverseBlock_forEmptyArray.
@Test
public void rendersInverseBlock_forEmptyArray() throws IOException {
// given
final ArrayNode arrayWithSimpleValues = new ArrayNode(jsonFactory);
// when
final Options.Buffer actualBuffer = helper.apply(arrayWithSimpleValues, options);
// then
then(actualBuffer).should().append(OptionsStub.TEMPLATE_CONTENT_FROM_INVERSE_BLOCK);
assertThat("Returns buffer provided by Handlebars through Options.", buffer, sameInstance(actualBuffer));
}
use of com.github.jknack.handlebars.Options in project hippo by NHS-digital-website.
the class TypeAnyHelperTest method rendersEmptyString_forModelOfIgnoredType.
@Test
public void rendersEmptyString_forModelOfIgnoredType() throws IOException {
// given
final String typeToIgnoreName = "java.util.Map";
// noinspection rawtypes
final Map modelOfIgnoredType = new HashMap();
options = OptionsStub.with(buffer, OptionsStub.Hash.of("ignoreClass", typeToIgnoreName));
// when
final Options.Buffer actualBuffer = helper.apply(modelOfIgnoredType, options);
// then
then(actualBuffer).should().append(EMPTY_STRING);
assertThat("Returns buffer provided by Handlebars through Options.", buffer, sameInstance(actualBuffer));
}
use of com.github.jknack.handlebars.Options in project ddf by codice.
the class DescriptionTemplateHelperTest method testThumbnailHasThumbnail.
@Test
public void testThumbnailHasThumbnail() throws IOException {
String ifOption = "if";
String elseOption = "else";
MetacardImpl metacard = new MetacardImpl();
metacard.setThumbnail(new byte[] { 1, 2, 3 });
Options mockOptions = mock(Options.class);
when(mockOptions.fn()).thenReturn(ifOption);
when(mockOptions.inverse()).thenReturn(elseOption);
String result = helper.hasThumbnail(metacard, mockOptions).toString();
assertEquals(ifOption, result);
}
Aggregations