Skip to content

Commit

Permalink
Qute: add MapTemplateExtensionsTest
Browse files Browse the repository at this point in the history
  • Loading branch information
mkouba committed Jun 15, 2023
1 parent c7c7370 commit 90149c9
Showing 1 changed file with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package io.quarkus.qute.deployment.extensions;

import static org.junit.jupiter.api.Assertions.assertEquals;

import java.util.Map;

import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import io.quarkus.qute.CheckedTemplate;
import io.quarkus.qute.TemplateInstance;
import io.quarkus.test.QuarkusUnitTest;

public class MapTemplateExtensionsTest {

@RegisterExtension
static final QuarkusUnitTest config = new QuarkusUnitTest()
.withApplicationRoot(root -> root
.addClass(Templates.class)
.addAsResource(new StringAsset(
"{map.foo}::{map['bar']}::{map.containsKey('foo')}::{map.empty}::{map.get('foo')}"),
"templates/map.html"));

@Test
public void testMap() {
assertEquals("1::5::true::false::1", Templates.map(Map.of("foo", 1, "bar", 5)).render());
}

@CheckedTemplate(basePath = "")
public static class Templates {

static native TemplateInstance map(Map<String, Object> map);
}

}

0 comments on commit 90149c9

Please sign in to comment.