|
1 | 1 | module Test.Main where |
2 | 2 |
|
3 | 3 | import Prelude |
| 4 | +import Control.Monad.Error.Class (class MonadThrow) |
| 5 | +import Data.String.Casing as Casing |
4 | 6 | import Effect (Effect) |
5 | | -import Effect.Class.Console (log) |
| 7 | +import Effect.Aff (Error, launchAff_) |
| 8 | +import Test.Spec (SpecT, describe, it) |
| 9 | +import Test.Spec.Assertions (shouldEqual) |
| 10 | +import Test.Spec.Reporter (consoleReporter) |
| 11 | +import Test.Spec.Runner (runSpec) |
| 12 | + |
| 13 | +makeTest :: |
| 14 | + forall t4 t7. |
| 15 | + Monad t7 => |
| 16 | + MonadThrow Error t4 => |
| 17 | + (String -> String) -> String -> String -> SpecT t4 Unit t7 Unit |
| 18 | +makeTest transform value expected = |
| 19 | + it ("properly converts \"" <> value <> "\" to \"" <> expected <> "\"") do |
| 20 | + transform value `shouldEqual` expected |
6 | 21 |
|
7 | 22 | main :: Effect Unit |
8 | 23 | main = do |
9 | | - log "🍝" |
10 | | - log "You should add some tests." |
| 24 | + launchAff_ |
| 25 | + $ runSpec [ consoleReporter ] do |
| 26 | + describe "Casing.toCamelCase" do |
| 27 | + let |
| 28 | + test = makeTest Casing.toCamelCase |
| 29 | + test "camelCase" "camelCase" |
| 30 | + test "PascalCase" "pascalCase" |
| 31 | + test "snake_case" "snakeCase" |
| 32 | + test "SCREAMING_SNAKE_CASE" "screamingSnakeCase" |
| 33 | + test "kebab-case" "kebabCase" |
| 34 | + test "Title Case" "titleCase" |
| 35 | + test "XMLHttpRequest" "xmlHttpRequest" |
| 36 | + test "PlayerID" "playerId" |
| 37 | + test "IODevice" "ioDevice" |
| 38 | + test "NASA" "nasa" |
| 39 | + test "Two Spaces" "twoSpaces" |
| 40 | + test "Three Spaces" "threeSpaces" |
| 41 | + test "Two__Underscores" "twoUnderscores" |
| 42 | + test "Three___Underscores" "threeUnderscores" |
| 43 | + test "this-contains_ ALLKinds OfWord_Boundaries" "thisContainsAllKindsOfWordBoundaries" |
| 44 | + describe "Casing.toSnakeCase" do |
| 45 | + let |
| 46 | + test = makeTest Casing.toSnakeCase |
| 47 | + test "camelCase" "camel_case" |
| 48 | + test "PascalCase" "pascal_case" |
| 49 | + test "snake_case" "snake_case" |
| 50 | + test "SCREAMING_SNAKE_CASE" "screaming_snake_case" |
| 51 | + test "kebab-case" "kebab_case" |
| 52 | + test "Title Case" "title_case" |
| 53 | + test "XMLHttpRequest" "xml_http_request" |
| 54 | + test "PlayerID" "player_id" |
| 55 | + test "IODevice" "io_device" |
| 56 | + test "NASA" "nasa" |
| 57 | + test "Two Spaces" "two_spaces" |
| 58 | + test "Three Spaces" "three_spaces" |
| 59 | + test "Two__Underscores" "two_underscores" |
| 60 | + test "Three___Underscores" "three_underscores" |
| 61 | + test "this-contains_ ALLKinds OfWord_Boundaries" "this_contains_all_kinds_of_word_boundaries" |
| 62 | + describe "Casing.toScreamingSnakeCase" do |
| 63 | + let |
| 64 | + test = makeTest Casing.toScreamingSnakeCase |
| 65 | + test "camelCase" "CAMEL_CASE" |
| 66 | + test "PascalCase" "PASCAL_CASE" |
| 67 | + test "snake_case" "SNAKE_CASE" |
| 68 | + test "SCREAMING_SNAKE_CASE" "SCREAMING_SNAKE_CASE" |
| 69 | + test "kebab-case" "KEBAB_CASE" |
| 70 | + test "Title Case" "TITLE_CASE" |
| 71 | + test "XMLHttpRequest" "XML_HTTP_REQUEST" |
| 72 | + test "PlayerID" "PLAYER_ID" |
| 73 | + test "IODevice" "IO_DEVICE" |
| 74 | + test "NASA" "NASA" |
| 75 | + test "Two Spaces" "TWO_SPACES" |
| 76 | + test "Three Spaces" "THREE_SPACES" |
| 77 | + test "Two__Underscores" "TWO_UNDERSCORES" |
| 78 | + test "Three___Underscores" "THREE_UNDERSCORES" |
| 79 | + test "this-contains_ ALLKinds OfWord_Boundaries" "THIS_CONTAINS_ALL_KINDS_OF_WORD_BOUNDARIES" |
| 80 | + describe "Casing.toKebabCase" do |
| 81 | + let |
| 82 | + test = makeTest Casing.toKebabCase |
| 83 | + test "camelCase" "camel-case" |
| 84 | + test "PascalCase" "pascal-case" |
| 85 | + test "snake_case" "snake-case" |
| 86 | + test "SCREAMING_SNAKE_CASE" "screaming-snake-case" |
| 87 | + test "kebab-case" "kebab-case" |
| 88 | + test "Title Case" "title-case" |
| 89 | + test "XMLHttpRequest" "xml-http-request" |
| 90 | + test "PlayerID" "player-id" |
| 91 | + test "IODevice" "io-device" |
| 92 | + test "NASA" "nasa" |
| 93 | + test "Two Spaces" "two-spaces" |
| 94 | + test "Three Spaces" "three-spaces" |
| 95 | + test "Two__Underscores" "two-underscores" |
| 96 | + test "Three___Underscores" "three-underscores" |
| 97 | + test "this-contains_ ALLKinds OfWord_Boundaries" "this-contains-all-kinds-of-word-boundaries" |
| 98 | + describe "Casing.toTitleCase" do |
| 99 | + let |
| 100 | + test = makeTest Casing.toTitleCase |
| 101 | + test "camelCase" "Camel Case" |
| 102 | + test "PascalCase" "Pascal Case" |
| 103 | + test "snake_case" "Snake Case" |
| 104 | + test "SCREAMING_SNAKE_CASE" "Screaming Snake Case" |
| 105 | + test "kebab-case" "Kebab Case" |
| 106 | + test "Title Case" "Title Case" |
| 107 | + test "XMLHttpRequest" "Xml Http Request" |
| 108 | + test "PlayerID" "Player Id" |
| 109 | + test "IODevice" "Io Device" |
| 110 | + test "NASA" "Nasa" |
| 111 | + test "Two Spaces" "Two Spaces" |
| 112 | + test "Three Spaces" "Three Spaces" |
| 113 | + test "Two__Underscores" "Two Underscores" |
| 114 | + test "Three___Underscores" "Three Underscores" |
| 115 | + test "this-contains_ ALLKinds OfWord_Boundaries" "This Contains All Kinds Of Word Boundaries" |
0 commit comments