commonTest.jetbrains.datalore.vis.svg.SvgAttributeTest.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of vis-svg-portable Show documentation
Show all versions of vis-svg-portable Show documentation
The Let-Plot Kotlin API depends on this artifact.
/*
* Copyright (c) 2019. JetBrains s.r.o.
* Use of this source code is governed by the MIT license that can be found in the LICENSE file.
*/
package jetbrains.datalore.vis.svg
import kotlin.test.BeforeTest
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertNull
class SvgAttributeTest {
private var element: SvgEllipseElement? = null
@BeforeTest
fun setUp() {
element = SvgEllipseElement(10.0, 20.0, 30.0, 40.0)
}
private fun elem() = element as SvgEllipseElement
@Test
fun testSetAttr() {
elem().cx().set(100.0)
elem().getAttribute("fill").set("yellow")
elem().setAttribute("stroke", "black")
assertEquals(100.0, elem().cx().get())
assertEquals("yellow", elem().getAttribute("fill").get())
assertEquals("black", elem().getAttribute("stroke").get())
}
@Test
fun testNotSetAttr() {
assertNull(elem().getAttribute("fill").get())
}
@Test
fun testResetAttr() {
elem().setAttribute("fill", "yellow")
elem().getAttribute("fill").set("red")
assertEquals("red", elem().getAttribute("fill").get())
}
}