Skip to content

Commit 82c125e

Browse files
committed
Port over the test suite
1 parent 487debc commit 82c125e

File tree

3 files changed

+119
-4
lines changed

3 files changed

+119
-4
lines changed

spago.dhall

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010
, "unicode"
1111
]
1212
, packages = ./packages.dhall
13-
, sources = [ "src/**/*.purs", "test/**/*.purs" ]
13+
, sources = [ "src/**/*.purs" ]
1414
}

test/Main.purs

Lines changed: 108 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,115 @@
11
module Test.Main where
22

33
import Prelude
4+
import Control.Monad.Error.Class (class MonadThrow)
5+
import Data.String.Casing as Casing
46
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
621

722
main :: Effect Unit
823
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"

test/test.dhall

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
let conf = ../spago.dhall
2+
in conf //
3+
{ dependencies =
4+
conf.dependencies #
5+
[ "spec" ]
6+
, sources =
7+
conf.sources #
8+
[ "test/**/*.purs"
9+
]
10+
}

0 commit comments

Comments
 (0)