com.github.mvysny.kaributesting.v8.Notifications.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of karibu-testing-v8 Show documentation
Show all versions of karibu-testing-v8 Show documentation
Karibu Testing, support for browserless Vaadin testing in Kotlin
The newest version!
package com.github.mvysny.kaributesting.v8
import com.vaadin.ui.Notification
import com.vaadin.ui.UI
/**
* Returns the list of currently displayed notifications.
*/
public fun getNotifications(): List = UI.getCurrent().extensions.filterIsInstance()
/**
* Expects that given list of notifications is displayed. Also clears the notifications.
*/
public fun expectNotifications(vararg descriptions: Pair) {
val notifications: List = getNotifications()
expectList(*descriptions) { notifications.map { it.caption to it.description } }
clearNotifications()
}
/**
* Expects that there are no notifications displayed.
*/
public fun expectNoNotifications() {
expectNotifications()
}
/**
* Clears and removes all notifications from screen.
*/
public fun clearNotifications() {
getNotifications().forEach { it.remove() }
}