From f0aaa63e6031a20b48982647b42ac8f5077145b2 Mon Sep 17 00:00:00 2001 From: Shagen Ogandzhanian Date: Wed, 9 Jun 2021 18:44:50 +0200 Subject: [PATCH] Add test for testing arithmetic in composable context --- web/core/src/jsTest/kotlin/CSSUnitApiTests.kt | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/web/core/src/jsTest/kotlin/CSSUnitApiTests.kt b/web/core/src/jsTest/kotlin/CSSUnitApiTests.kt index bfc8119dba..69e08a6153 100644 --- a/web/core/src/jsTest/kotlin/CSSUnitApiTests.kt +++ b/web/core/src/jsTest/kotlin/CSSUnitApiTests.kt @@ -5,6 +5,10 @@ package org.jetbrains.compose.web.core.tests +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue import org.jetbrains.compose.web.css.ch import org.jetbrains.compose.web.css.cm import org.jetbrains.compose.web.css.cssRem @@ -16,6 +20,7 @@ import org.jetbrains.compose.web.css.dppx import org.jetbrains.compose.web.css.em import org.jetbrains.compose.web.css.fr import org.jetbrains.compose.web.css.grad +import org.jetbrains.compose.web.css.left import org.jetbrains.compose.web.css.minus import org.jetbrains.compose.web.css.mm import org.jetbrains.compose.web.css.ms @@ -28,11 +33,15 @@ import org.jetbrains.compose.web.css.px import org.jetbrains.compose.web.css.rad import org.jetbrains.compose.web.css.s import org.jetbrains.compose.web.css.times +import org.jetbrains.compose.web.css.top import org.jetbrains.compose.web.css.turn import org.jetbrains.compose.web.css.vh import org.jetbrains.compose.web.css.vmax import org.jetbrains.compose.web.css.vmin import org.jetbrains.compose.web.css.vw +import org.jetbrains.compose.web.dom.Div +import org.w3c.dom.HTMLElement +import org.w3c.dom.get import kotlin.test.Test import kotlin.test.assertEquals @@ -296,4 +305,23 @@ class CSSUnitApiTests { assertEquals(1.fr, 7.fr - 4.fr - 2.fr) } + + @Test + fun staticEvaluation() = runTest { + composition { + Div({ + var a = 5.px + style { + val b = a + 3.px + left(a) + top(b) + a = 20.px + } + }) + } + + + assertEquals("5px", (root.children[0] as HTMLElement).style.left) + assertEquals("8px", (root.children[0] as HTMLElement).style.top) + } } \ No newline at end of file