use of com.github.jknack.handlebars.Options in project hippo by NHS-digital-website.
the class IsAnyTrueHelperTest method throwExceptionWhenAtLeastOneIsNull.
@Test
public void throwExceptionWhenAtLeastOneIsNull() {
final Boolean[] params = { false, null };
final Options options = OptionsStub.with(params, buffer);
try {
// when
isAnyTrueHelper.apply(item, options);
fail("An exception was expected but none was thrown.");
} catch (Exception e) {
// then
assertThat("Exception in execution", e.getMessage(), containsString("All parameters are required to be boolean but at least one provided value was not."));
}
}
use of com.github.jknack.handlebars.Options in project hippo by NHS-digital-website.
the class IsAnyTrueHelperTest method rendersBlockWhenCollectionHasAtLeastOneTrueItem.
@Test
public void rendersBlockWhenCollectionHasAtLeastOneTrueItem() throws IOException {
final Boolean[] params = { false, false, true, false, false };
final Options options = OptionsStub.with(params, buffer);
// when
final Options.Buffer actualBuffer = (Options.Buffer) isAnyTrueHelper.apply(item, options);
// then
assertThat("Returns Options.Buffer", buffer, sameInstance(actualBuffer));
then(actualBuffer).should().append(TEMPLATE_CONTENT_FROM_MAIN_BLOCK);
}
use of com.github.jknack.handlebars.Options in project hippo by NHS-digital-website.
the class IsAnyTrueHelperTest method throwExceptionWhenCollectionIsEmpty.
@Test
public void throwExceptionWhenCollectionIsEmpty() throws IOException {
final Boolean[] params = {};
final Options options = OptionsStub.with(params, buffer);
try {
// when
isAnyTrueHelper.apply(item, options);
fail("An exception was expected but none was thrown.");
} catch (IllegalArgumentException e) {
// then
assertThat("Exception in execution", e.getMessage(), containsString("At least one parameter is required but none was provided."));
}
}
use of com.github.jknack.handlebars.Options in project hippo by NHS-digital-website.
the class TypeAnyHelperTest method rendersInverseBlock_forArrayOfSimpleValues.
@Test
public void rendersInverseBlock_forArrayOfSimpleValues() throws IOException {
// given
final ArrayNode arrayWithSimpleValues = new ArrayNode(jsonFactory).add("simple value");
// 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_whenModelIsNull.
@Test
public void rendersEmptyString_whenModelIsNull() throws IOException {
// given
final ObjectNode nullObject = null;
// when
final Options.Buffer actualBuffer = helper.apply(nullObject, options);
// then
then(actualBuffer).should().append(EMPTY_STRING);
assertThat("Returns buffer provided by Handlebars through Options.", buffer, sameInstance(actualBuffer));
}
Aggregations