summaryrefslogtreecommitdiff
path: root/examples/scala-js/examples/testing/src/test/scala/ElementCreatorTest.scala
diff options
context:
space:
mode:
Diffstat (limited to 'examples/scala-js/examples/testing/src/test/scala/ElementCreatorTest.scala')
-rw-r--r--examples/scala-js/examples/testing/src/test/scala/ElementCreatorTest.scala24
1 files changed, 24 insertions, 0 deletions
diff --git a/examples/scala-js/examples/testing/src/test/scala/ElementCreatorTest.scala b/examples/scala-js/examples/testing/src/test/scala/ElementCreatorTest.scala
new file mode 100644
index 0000000..43f6756
--- /dev/null
+++ b/examples/scala-js/examples/testing/src/test/scala/ElementCreatorTest.scala
@@ -0,0 +1,24 @@
+import scala.scalajs.js
+import scala.scalajs.js.Dynamic.global
+
+import org.scalajs.jasminetest.JasmineTest
+
+object ElementCreatorTest extends JasmineTest {
+
+ describe("ElementCreator") {
+
+ it("should be able to create an element in the body") {
+ // create the element
+ ElementCreator.create()
+
+ // jquery would make this easier, but I wanted to
+ // only use pure html in the test itself
+ val body = global.document.getElementsByTagName("body")
+ .asInstanceOf[js.Array[js.Dynamic]].head
+
+ // the Scala.js DOM API would make this easier
+ expect(body.lastChild.tagName.toString == "H1").toBeTruthy
+ expect(body.lastChild.innerHTML.toString == "Test").toBeTruthy
+ }
+ }
+}