summaryrefslogtreecommitdiff
path: root/examples/scala-js/jasmine-test-framework/src/main/scala/org/scalajs/jasminetest/TestSuiteContext.scala
diff options
context:
space:
mode:
authorHaoyi Li <haoyi@haoyi-mbp.corp.dropbox.com>2014-11-26 00:45:31 -0800
committerHaoyi Li <haoyi@haoyi-mbp.corp.dropbox.com>2014-11-26 00:45:31 -0800
commit24f31e120f9537faede7a174bb09ee35f64e1ce4 (patch)
tree06ffc3ecc7847789008352b7e2b7c040dad48907 /examples/scala-js/jasmine-test-framework/src/main/scala/org/scalajs/jasminetest/TestSuiteContext.scala
parentb89ce9cbf79363f8cab09186a5d7ba94bc0af02a (diff)
parent2c4b142503bd2d871e6818b5cab8c38627d9e4a0 (diff)
downloadhands-on-scala-js-24f31e120f9537faede7a174bb09ee35f64e1ce4.tar.gz
hands-on-scala-js-24f31e120f9537faede7a174bb09ee35f64e1ce4.tar.bz2
hands-on-scala-js-24f31e120f9537faede7a174bb09ee35f64e1ce4.zip
Merge commit '2c4b142503bd2d871e6818b5cab8c38627d9e4a0' as 'examples/scala-js'
Diffstat (limited to 'examples/scala-js/jasmine-test-framework/src/main/scala/org/scalajs/jasminetest/TestSuiteContext.scala')
-rw-r--r--examples/scala-js/jasmine-test-framework/src/main/scala/org/scalajs/jasminetest/TestSuiteContext.scala55
1 files changed, 55 insertions, 0 deletions
diff --git a/examples/scala-js/jasmine-test-framework/src/main/scala/org/scalajs/jasminetest/TestSuiteContext.scala b/examples/scala-js/jasmine-test-framework/src/main/scala/org/scalajs/jasminetest/TestSuiteContext.scala
new file mode 100644
index 0000000..827eefd
--- /dev/null
+++ b/examples/scala-js/jasmine-test-framework/src/main/scala/org/scalajs/jasminetest/TestSuiteContext.scala
@@ -0,0 +1,55 @@
+/* __ *\
+** ________ ___ / / ___ __ ____ Scala.js Test Framework **
+** / __/ __// _ | / / / _ | __ / // __/ (c) 2013, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ |/_// /_\ \ http://scala-js.org/ **
+** /____/\___/_/ |_/____/_/ | |__/ /____/ **
+** |/____/ **
+\* */
+
+
+package org.scalajs.jasminetest
+
+trait TestSuiteContext {
+ def describe(title: String)(test: => Unit): Unit
+ def it(title: String)(test: => Unit): Unit
+ def xdescribe(title: String)(test: => Unit): Unit
+ def xit(title: String)(test: => Unit): Unit
+
+ def when(tag: String): TestSuiteContext =
+ if (JasmineTestFramework.hasTag(tag)) this
+ else new TestSuiteContext.IgnoredContext(this)
+
+ def whenAll(tags: String*): TestSuiteContext =
+ if (tags.forall(JasmineTestFramework.hasTag)) this
+ else new TestSuiteContext.IgnoredContext(this)
+
+ def whenAny(tags: String*): TestSuiteContext =
+ if (tags.exists(JasmineTestFramework.hasTag)) this
+ else new TestSuiteContext.IgnoredContext(this)
+
+ def unless(tag: String): TestSuiteContext =
+ if (!JasmineTestFramework.hasTag(tag)) this
+ else new TestSuiteContext.IgnoredContext(this)
+
+ def unlessAll(tags: String*): TestSuiteContext =
+ if (!tags.forall(JasmineTestFramework.hasTag)) this
+ else new TestSuiteContext.IgnoredContext(this)
+
+ def unlessAny(tags: String*): TestSuiteContext =
+ if (!tags.exists(JasmineTestFramework.hasTag)) this
+ else new TestSuiteContext.IgnoredContext(this)
+}
+
+object TestSuiteContext {
+ private class IgnoredContext(
+ baseContext: TestSuiteContext) extends TestSuiteContext {
+ def describe(title: String)(test: => Unit): Unit =
+ baseContext.xdescribe(title)(test)
+ def it(title: String)(test: => Unit): Unit =
+ baseContext.xit(title)(test)
+ def xdescribe(title: String)(test: => Unit): Unit =
+ baseContext.xdescribe(title)(test)
+ def xit(title: String)(test: => Unit): Unit =
+ baseContext.xit(title)(test)
+ }
+}