Skip to content

Commit bb61a20

Browse files
authored
Merge pull request #44 from joneshf/cleanup-tests
Cleanup tests
2 parents 45de025 + 11e3f2b commit bb61a20

2 files changed

+13
-46
lines changed

test/HowTo.DecodeAndEncodeJSONWithOptionalValuesInPureScriptSimpleJSON.purs

Lines changed: 12 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -23,91 +23,58 @@ writeJSON = Simple.JSON.writeJSON
2323

2424
spec :: Test.Spec.Spec Unit
2525
spec =
26-
Test.Spec.describe "HowTo.DecodeAndEncodeJSONWithOptionalValuesInPureScriptArgonaut" do
26+
Test.Spec.describe "HowTo.DecodeAndEncodeJSONWithOptionalValuesInPureScriptSimpleJSON" do
2727
spec_readJSON
2828
spec_writeJSON
2929

3030
spec_readJSON :: Test.Spec.Spec Unit
3131
spec_readJSON =
3232
Test.Spec.describe "readJSON" do
3333
Test.Spec.it "doesn't require any fields" do
34-
let
35-
json :: String
36-
json = """{}"""
3734
Test.Spec.Assertions.shouldEqual
38-
(readJSON json)
35+
(readJSON """{}""")
3936
(Data.Either.Right (Option.fromRecord {}))
4037
Test.Spec.it "accepts only a name" do
41-
let
42-
json :: String
43-
json = """{ "name": "Pat" }"""
4438
Test.Spec.Assertions.shouldEqual
45-
(readJSON json)
39+
(readJSON """{ "name": "Pat" }""")
4640
(Data.Either.Right (Option.fromRecord { name: "Pat" }))
4741
Test.Spec.it "accepts only a title" do
48-
let
49-
json :: String
50-
json = """{ "title": "wonderful" }"""
5142
Test.Spec.Assertions.shouldEqual
52-
(readJSON json)
43+
(readJSON """{ "title": "wonderful" }""")
5344
(Data.Either.Right (Option.fromRecord { title: "wonderful" }))
5445
Test.Spec.it "accepts both a name and a title" do
55-
let
56-
json :: String
57-
json = """{ "name": "Pat", "title": "Dr." }"""
5846
Test.Spec.Assertions.shouldEqual
59-
(readJSON json)
47+
(readJSON """{ "name": "Pat", "title": "Dr." }""")
6048
(Data.Either.Right (Option.fromRecord { name: "Pat", title: "Dr." }))
6149
Test.Spec.it "doesn't fail a null name" do
62-
let
63-
json :: String
64-
json = """{ "name": null }"""
6550
Test.Spec.Assertions.shouldEqual
66-
(readJSON json)
51+
(readJSON """{ "name": null }""")
6752
(Data.Either.Right (Option.fromRecord {}))
6853
Test.Spec.it "doesn't fail for a null title" do
69-
let
70-
json :: String
71-
json = """{ "title": null }"""
7254
Test.Spec.Assertions.shouldEqual
73-
(readJSON json)
55+
(readJSON """{ "title": null }""")
7456
(Data.Either.Right (Option.fromRecord {}))
7557
Test.Spec.it "doesn't fail for a null name or title" do
76-
let
77-
json :: String
78-
json = """{ "name": null, "title": null }"""
7958
Test.Spec.Assertions.shouldEqual
80-
(readJSON json)
59+
(readJSON """{ "name": null, "title": null }""")
8160
(Data.Either.Right (Option.fromRecord {}))
8261

8362
spec_writeJSON :: Test.Spec.Spec Unit
8463
spec_writeJSON =
8564
Test.Spec.describe "writeJSON" do
8665
Test.Spec.it "inserts no fields if none exist" do
87-
let
88-
option :: Option.Option ( name :: String, title :: String )
89-
option = Option.fromRecord {}
9066
Test.Spec.Assertions.shouldEqual
91-
(writeJSON option)
67+
(writeJSON (Option.fromRecord {}))
9268
"{}"
9369
Test.Spec.it "inserts a name if it exist" do
94-
let
95-
option :: Option.Option ( name :: String, title :: String )
96-
option = Option.fromRecord { name: "Pat" }
9770
Test.Spec.Assertions.shouldEqual
98-
(writeJSON option)
71+
(writeJSON (Option.fromRecord { name: "Pat" }))
9972
"{\"name\":\"Pat\"}"
10073
Test.Spec.it "inserts a title if it exist" do
101-
let
102-
option :: Option.Option ( name :: String, title :: String )
103-
option = Option.fromRecord { title: "wonderful" }
10474
Test.Spec.Assertions.shouldEqual
105-
(writeJSON option)
75+
(writeJSON (Option.fromRecord { title: "wonderful" }))
10676
"{\"title\":\"wonderful\"}"
10777
Test.Spec.it "inserts both a name and a title if they exist" do
108-
let
109-
option :: Option.Option ( name :: String, title :: String )
110-
option = Option.fromRecord { name: "Pat", title: "Dr." }
11178
Test.Spec.Assertions.shouldEqual
112-
(writeJSON option)
79+
(writeJSON (Option.fromRecord { name: "Pat", title: "Dr." }))
11380
"{\"title\":\"Dr.\",\"name\":\"Pat\"}"

test/HowTo.DecodeAndEncodeJSONWithRequiredAndOptionalValuesInPureScriptSimpleJSON.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ writeJSON = Simple.JSON.writeJSON
3232

3333
spec :: Test.Spec.Spec Unit
3434
spec =
35-
Test.Spec.describe "HowTo.DecodeAndEncodeJSONWithRequiredAndOptionalValuesInPureScriptArgonaut" do
35+
Test.Spec.describe "HowTo.DecodeAndEncodeJSONWithRequiredAndOptionalValuesInPureScriptSimpleJSON" do
3636
spec_parse
3737
spec_writeJSON
3838

0 commit comments

Comments
 (0)