Search in sources :

Example 1 with LESSContext

use of org.xwiki.lesscss.internal.LESSContext in project xwiki-platform by xwiki.

the class LESSExportActionListenerTest method onEventWhenHTMLExport.

@Test
public void onEventWhenHTMLExport() throws Exception {
    XWikiContext xcontext = mock(XWikiContext.class);
    XWikiRequest request = mock(XWikiRequest.class);
    when(xcontext.getRequest()).thenReturn(request);
    when(request.get("format")).thenReturn("html");
    this.mocker.getComponentUnderTest().onEvent(new ActionExecutingEvent("export"), null, xcontext);
    // The test is here: we verify that the cache is disabled!
    LESSContext lessContext = mocker.getInstance(LESSContext.class);
    verify(lessContext).setHtmlExport(true);
}
Also used : XWikiRequest(com.xpn.xwiki.web.XWikiRequest) LESSContext(org.xwiki.lesscss.internal.LESSContext) XWikiContext(com.xpn.xwiki.XWikiContext) ActionExecutingEvent(org.xwiki.bridge.event.ActionExecutingEvent) Test(org.junit.Test)

Example 2 with LESSContext

use of org.xwiki.lesscss.internal.LESSContext in project xwiki-platform by xwiki.

the class LESSExportActionListenerTest method onEventWhenNonHTMLExport.

@Test
public void onEventWhenNonHTMLExport() throws Exception {
    XWikiContext xcontext = mock(XWikiContext.class);
    XWikiRequest request = mock(XWikiRequest.class);
    when(xcontext.getRequest()).thenReturn(request);
    when(request.get("format")).thenReturn("xar");
    this.mocker.getComponentUnderTest().onEvent(new ActionExecutingEvent("export"), null, xcontext);
    // The test is here: we verify that the we do not disable the LESS cache (since the export is not an HTML
    // export). Actually that the context object was not called at all...
    LESSContext lessContext = mocker.getInstance(LESSContext.class);
    verifyZeroInteractions(lessContext);
}
Also used : XWikiRequest(com.xpn.xwiki.web.XWikiRequest) LESSContext(org.xwiki.lesscss.internal.LESSContext) XWikiContext(com.xpn.xwiki.XWikiContext) ActionExecutingEvent(org.xwiki.bridge.event.ActionExecutingEvent) Test(org.junit.Test)

Aggregations

XWikiContext (com.xpn.xwiki.XWikiContext)2 XWikiRequest (com.xpn.xwiki.web.XWikiRequest)2 Test (org.junit.Test)2 ActionExecutingEvent (org.xwiki.bridge.event.ActionExecutingEvent)2 LESSContext (org.xwiki.lesscss.internal.LESSContext)2