use of com.adobe.cq.wcm.core.components.models.ClientLibraries in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class ClientLibrariesImplTest method testGetCategoriesForComponent.
@Test
void testGetCategoriesForComponent() {
Resource accordionResource = context.currentResource(ACCORDION_PATH);
Map<String, Object> attributes = new HashMap<>();
attributes.put(ClientLibraries.OPTION_RESOURCE_TYPES, Utils.getResourceTypes(accordionResource, context.request(), mock(ModelFactory.class)));
ClientLibraries clientlibs = getClientLibrariesUnderTest(ACCORDION_PATH, attributes);
Set<String> categories = new HashSet<>();
categories.add(TEASER_CATEGORY);
categories.add(ACCORDION_CATEGORY);
assertEquals(categories, ((ClientLibrariesImpl) clientlibs).getCategoriesFromComponents());
}
use of com.adobe.cq.wcm.core.components.models.ClientLibraries in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class ClientLibrariesImplTest method testGetCategoriesWithInjectedResourceTypesAndInheritance.
@Test
void testGetCategoriesWithInjectedResourceTypesAndInheritance() {
Map<String, Object> attributes = new HashMap<>();
attributes.put("resourceTypes", new HashSet<String>() {
{
add("core/wcm/components/accordion/v1/accordion");
add("core/wcm/components/carousel/v3/carousel");
}
});
ClientLibraries clientlibs = getClientLibrariesUnderTest(ROOT_PAGE, attributes);
StringBuilder includes = new StringBuilder();
includes.append(jsIncludes.get(ACCORDION_CATEGORY));
includes.append(jsIncludes.get(CAROUSEL_CATEGORY));
includes.append(cssIncludes.get(ACCORDION_CATEGORY));
includes.append(cssIncludes.get(CAROUSEL_CATEGORY));
assertEquals(includes.toString(), clientlibs.getJsAndCssIncludes());
}
use of com.adobe.cq.wcm.core.components.models.ClientLibraries in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class ClientLibrariesImplTest method testJsInline.
@Test
void testJsInline() {
Map<String, Object> attributes = new HashMap<>();
attributes.put("categories", TEASER_CATEGORY + "," + ACCORDION_CATEGORY + "," + CAROUSEL_CATEGORY);
ClientLibraries clientlibs = getClientLibrariesUnderTest(ROOT_PAGE, attributes);
StringBuilder jsInline = new StringBuilder();
jsInline.append(jsInlines.get(TEASER_CATEGORY));
jsInline.append(jsInlines.get(ACCORDION_CATEGORY));
jsInline.append(jsInlines.get(CAROUSEL_CATEGORY));
assertEquals(jsInline.toString(), clientlibs.getJsInline());
}
use of com.adobe.cq.wcm.core.components.models.ClientLibraries in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class ClientLibrariesImplTest method testGetCategoriesWithInjectedFilter.
@Test
void testGetCategoriesWithInjectedFilter() {
PageManager pageManager = context.resourceResolver().adaptTo(PageManager.class);
Page page = pageManager.getPage(ROOT_PAGE);
Map<String, Object> attributes = new HashMap<>();
attributes.put(ClientLibraries.OPTION_RESOURCE_TYPES, Utils.getPageResourceTypes(page, context.request(), mock(ModelFactory.class)));
attributes.put("filter", ".*teaser.*");
ClientLibraries clientlibs = getClientLibrariesUnderTest(ROOT_PAGE, attributes);
Set<String> categories = new HashSet<>();
categories.add(TEASER_CATEGORY);
assertEquals(categories, ((ClientLibrariesImpl) clientlibs).getCategoriesFromComponents());
}
use of com.adobe.cq.wcm.core.components.models.ClientLibraries in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class ClientLibrariesImplTest method testGetCssInline.
@Test
void testGetCssInline() {
Map<String, Object> attributes = new HashMap<>();
attributes.put("categories", TEASER_CATEGORY + "," + ACCORDION_CATEGORY + "," + CAROUSEL_CATEGORY);
ClientLibraries clientlibs = getClientLibrariesUnderTest(ROOT_PAGE, attributes);
StringBuilder cssInline = new StringBuilder();
cssInline.append(cssInlines.get(TEASER_CATEGORY));
cssInline.append(cssInlines.get(ACCORDION_CATEGORY));
cssInline.append(cssInlines.get(CAROUSEL_CATEGORY));
assertEquals(cssInline.toString(), clientlibs.getCssInline());
}
Aggregations