All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonTest.jetbrains.datalore.vis.svg.SvgTextElementTest.kt Maven / Gradle / Ivy

There is a newer version: 3.2.0
Show newest version
/*
 * 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.Test
import kotlin.test.assertSame
import kotlin.test.assertTrue

class SvgTextElementTest {
    private val str = "Some text"
    private val altStr = "Some other text"

    @Test
    fun initEmpty() {
        val element = SvgTextElement()
        assertTrue(element.children().isEmpty())
    }

    @Test
    fun initString() {
        val element = SvgTextElement(str)
        assertSame(1, element.children().size)
        assertSame((element.children()[0] as SvgTextNode).textContent().get(), str)
    }

    @Test
    fun setText() {
        val element = SvgTextElement(str)
        element.setTextNode(altStr)
        assertSame(1, element.children().size)
        assertSame((element.children()[0] as SvgTextNode).textContent().get(), altStr)
    }

    @Test
    fun addText() {
        val element = SvgTextElement(str)
        element.addTextNode(altStr)
        assertSame(2, element.children().size)
        assertSame((element.children()[0] as SvgTextNode).textContent().get(), str)
        assertSame((element.children()[1] as SvgTextNode).textContent().get(), altStr)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy