Search in sources :

Example 1 with Hash

use of uk.nhs.digital.common.components.apispecification.handlebars.OptionsStub.Hash in project hippo by NHS-digital-website.

the class IndentationHelperTest method returnsWeightedIndentationLevel_whenWeightingSet.

@Test
public void returnsWeightedIndentationLevel_whenWeightingSet() {
    // given
    final int ancestorCount = RandomUtils.nextInt();
    final double weighting = 1.5;
    final String expectedIndentationLevel = String.format("%.1f", ancestorCount * weighting);
    final Context context = Context.newContext(new Object());
    final ContextModelsStack contextModelsStack = mock(ContextModelsStack.class);
    given(contextModelsStack.ancestorModelsCount()).willReturn(ancestorCount);
    final ContextModelsStack.Factory contextStackFactory = mock(ContextModelsStack.Factory.class);
    given(contextStackFactory.from(context)).willReturn(contextModelsStack);
    final IndentationHelper indentationHelper = IndentationHelper.with(contextStackFactory);
    final Hash hash = Hash.of("weighting", weighting);
    final Options options = OptionsStub.with(context, hash);
    // when
    final String actualIndentationLevel = indentationHelper.apply(null, options);
    // then
    assertThat("Total number of ancestor Contexts is returned.", actualIndentationLevel, is(expectedIndentationLevel));
}
Also used : Context(com.github.jknack.handlebars.Context) Options(com.github.jknack.handlebars.Options) Hash(uk.nhs.digital.common.components.apispecification.handlebars.OptionsStub.Hash) Test(org.junit.Test)

Aggregations

Context (com.github.jknack.handlebars.Context)1 Options (com.github.jknack.handlebars.Options)1 Test (org.junit.Test)1 Hash (uk.nhs.digital.common.components.apispecification.handlebars.OptionsStub.Hash)1