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 13, 2023
1 parent 197c921 commit a0c1280
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.keys}::{map.empty}::{map.get('foo')}"),
"templates/map.html"));

@Test
public void testMap() {
assertEquals("1::5::[foo, bar]::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 a0c1280

Please sign in to comment.