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

com.github.mvysny.kaributesting.v8.Navigator.kt Maven / Gradle / Ivy

package com.github.mvysny.kaributesting.v8

import com.vaadin.navigator.View
import com.vaadin.ui.UI
import kotlin.test.expect
import kotlin.test.fail

/**
 * Returns the current view (last view that was navigated to). Returns null if there is no current UI, or there is no
 * navigator, or the navigator's current view is null.
 */
public val currentView: View? get() = UI.getCurrent()?.navigator?.currentView

/**
 * Expects that given [view] is the currently displayed view.
 */
public fun  expectView(view: Class) {
    @Suppress("UNCHECKED_CAST")
    expect(view as Class) { currentView?.javaClass }
}

/**
 * Expects that given view is the currently displayed view.
 */
public inline fun  expectView() {
    expectView(V::class.java)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy