MountOps

trait MountOps

Utilities for mounting / unmounting a single DOM node and running assertions on it. This functionality can be used with DOM nodes created by any means, you don't need to use Scala DOM Builder. This trait is agnostic of the testing frameworks. We have an adapter for ScalaTest, see MountSpec. Old versions used to have an adapter for ScalaTest.

class Object
trait Matchable
class Any

Value members

Abstract methods

def doAssert(condition: Boolean, message: String): Unit

If condition is false, fail the test with a given message This method exists for compatibility with different test frameworks.

If condition is false, fail the test with a given message This method exists for compatibility with different test frameworks.

def doFail(message: String): Nothing

Fail the test with a given message This method exists for compatibility with different test frameworks.

Fail the test with a given message This method exists for compatibility with different test frameworks.

Concrete methods

def assertEmptyContainer(clue: String): Unit
def assertRootNodeMounted(clue: String): Unit
def clearDOM(clue: String): Unit

Remove all traces of previous tests from the DOM: Unmount the root node and remove the container from the DOM

Remove all traces of previous tests from the DOM: Unmount the root node and remove the container from the DOM

def createContainer(): Element
def expectNode(expectedNode: ExpectedNode): Unit

Check that the root node matches the provided description. Call doFail with an error message if the test fails.

Check that the root node matches the provided description. Call doFail with an error message if the test fails.

def expectNode(actualNode: Node, expectedNode: ExpectedNode, clue: String): Unit

Check that a given node matches the provided description. Call doFail with an error message if the test fails.

Check that a given node matches the provided description. Call doFail with an error message if the test fails.

def mount(node: Node, clue: String): Unit

Inject the root node into the DOM

Inject the root node into the DOM

def mount(node: Node): Unit

Inject the root node into the DOM – with default clue Note: defaultMountedElementClue should not be made a default value on the above mount method because that prevents users from defining their own mount methods that accept default arguments ("multiple overloaded alternatives of method mount define default arguments") error

Inject the root node into the DOM – with default clue Note: defaultMountedElementClue should not be made a default value on the above mount method because that prevents users from defining their own mount methods that accept default arguments ("multiple overloaded alternatives of method mount define default arguments") error

def mount(clue: String, node: Node): Unit

Inject the root node into the DOM – alternative argument order for convenience

Inject the root node into the DOM – alternative argument order for convenience

def resetDOM(clue: String): Unit

Clear the DOM and create a new container. This should be called before each test.

Clear the DOM and create a new container. This should be called before each test.

def rootNode: Node

Root node is the node that we test in expectNode. It is the only child of the containerNode element

Root node is the node that we test in expectNode. It is the only child of the containerNode element

def unmount(clue: String): Unit

Remove root node from the DOM

Remove root node from the DOM

Concrete fields

var containerNode: Element

Container element that will hold the root node as a child. Container is mounted as a child of element

Container element that will hold the root node as a child. Container is mounted as a child of element

var mountedElementClue: String

Prefix to add to error messages – useful to differentiate between different mount() calls within one test

Prefix to add to error messages – useful to differentiate between different mount() calls within one test