-
Notifications
You must be signed in to change notification settings - Fork 222
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
308031e
commit 81a3797
Showing
3 changed files
with
55 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package sangria.util | ||
|
||
import org.scalatest.{Matchers, WordSpec} | ||
import sangria.util.StringUtil._ | ||
|
||
class StringUtilSpec extends WordSpec with Matchers { | ||
"camelCaseToUnderscore" should { | ||
"convert camel-case identifiers to underscore-based one" in { | ||
camelCaseToUnderscore("FooBar") should be ("foo_bar") | ||
camelCaseToUnderscore("Foo1Bar") should be ("foo1_bar") | ||
camelCaseToUnderscore("FooBar_Baz") should be ("foo_bar_baz") | ||
camelCaseToUnderscore("_Foo_Bar_") should be ("foo_bar") | ||
} | ||
} | ||
|
||
"quotedOrList" should { | ||
"Does not accept an empty list" in { | ||
an [IllegalArgumentException] should be thrownBy quotedOrList(Nil) | ||
} | ||
|
||
"Returns single quoted item" in { | ||
quotedOrList(Seq("A")) should be ("\"A\"") | ||
} | ||
|
||
"Returns two item list" in { | ||
quotedOrList(Seq("A", "B")) should be ("\"A\" or \"B\"") | ||
} | ||
|
||
"Returns comma separated many item list" in { | ||
quotedOrList(Seq("A", "B", "C")) should be ("\"A\", \"B\" or \"C\"") | ||
} | ||
|
||
"Limits to five items" in { | ||
quotedOrList(Seq("A", "B", "C", "D", "E", "F")) should be ("\"A\", \"B\", \"C\", \"D\" or \"E\"") | ||
} | ||
} | ||
} |