@@ -23,91 +23,58 @@ writeJSON = Simple.JSON.writeJSON
23
23
24
24
spec :: Test.Spec.Spec Unit
25
25
spec =
26
- Test.Spec .describe " HowTo.DecodeAndEncodeJSONWithOptionalValuesInPureScriptArgonaut " do
26
+ Test.Spec .describe " HowTo.DecodeAndEncodeJSONWithOptionalValuesInPureScriptSimpleJSON " do
27
27
spec_readJSON
28
28
spec_writeJSON
29
29
30
30
spec_readJSON :: Test.Spec.Spec Unit
31
31
spec_readJSON =
32
32
Test.Spec .describe " readJSON" do
33
33
Test.Spec .it " doesn't require any fields" do
34
- let
35
- json :: String
36
- json = """ {}"""
37
34
Test.Spec.Assertions .shouldEqual
38
- (readJSON json )
35
+ (readJSON """ {} """ )
39
36
(Data.Either.Right (Option .fromRecord {}))
40
37
Test.Spec .it " accepts only a name" do
41
- let
42
- json :: String
43
- json = """ { "name": "Pat" }"""
44
38
Test.Spec.Assertions .shouldEqual
45
- (readJSON json )
39
+ (readJSON """ { "name": "Pat" } """ )
46
40
(Data.Either.Right (Option .fromRecord { name: " Pat" }))
47
41
Test.Spec .it " accepts only a title" do
48
- let
49
- json :: String
50
- json = """ { "title": "wonderful" }"""
51
42
Test.Spec.Assertions .shouldEqual
52
- (readJSON json )
43
+ (readJSON """ { "title": "wonderful" } """ )
53
44
(Data.Either.Right (Option .fromRecord { title: " wonderful" }))
54
45
Test.Spec .it " accepts both a name and a title" do
55
- let
56
- json :: String
57
- json = """ { "name": "Pat", "title": "Dr." }"""
58
46
Test.Spec.Assertions .shouldEqual
59
- (readJSON json )
47
+ (readJSON """ { "name": "Pat", "title": "Dr." } """ )
60
48
(Data.Either.Right (Option .fromRecord { name: " Pat" , title: " Dr." }))
61
49
Test.Spec .it " doesn't fail a null name" do
62
- let
63
- json :: String
64
- json = """ { "name": null }"""
65
50
Test.Spec.Assertions .shouldEqual
66
- (readJSON json )
51
+ (readJSON """ { "name": null } """ )
67
52
(Data.Either.Right (Option .fromRecord {}))
68
53
Test.Spec .it " doesn't fail for a null title" do
69
- let
70
- json :: String
71
- json = """ { "title": null }"""
72
54
Test.Spec.Assertions .shouldEqual
73
- (readJSON json )
55
+ (readJSON """ { "title": null } """ )
74
56
(Data.Either.Right (Option .fromRecord {}))
75
57
Test.Spec .it " doesn't fail for a null name or title" do
76
- let
77
- json :: String
78
- json = """ { "name": null, "title": null }"""
79
58
Test.Spec.Assertions .shouldEqual
80
- (readJSON json )
59
+ (readJSON """ { "name": null, "title": null } """ )
81
60
(Data.Either.Right (Option .fromRecord {}))
82
61
83
62
spec_writeJSON :: Test.Spec.Spec Unit
84
63
spec_writeJSON =
85
64
Test.Spec .describe " writeJSON" do
86
65
Test.Spec .it " inserts no fields if none exist" do
87
- let
88
- option :: Option.Option ( name :: String , title :: String )
89
- option = Option.fromRecord { }
90
66
Test.Spec.Assertions .shouldEqual
91
- (writeJSON option )
67
+ (writeJSON ( Option .fromRecord {}) )
92
68
" {}"
93
69
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" }
97
70
Test.Spec.Assertions .shouldEqual
98
- (writeJSON option )
71
+ (writeJSON ( Option .fromRecord { name: " Pat " }) )
99
72
" {\" name\" :\" Pat\" }"
100
73
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" }
104
74
Test.Spec.Assertions .shouldEqual
105
- (writeJSON option )
75
+ (writeJSON ( Option .fromRecord { title: " wonderful " }) )
106
76
" {\" title\" :\" wonderful\" }"
107
77
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." }
111
78
Test.Spec.Assertions .shouldEqual
112
- (writeJSON option )
79
+ (writeJSON ( Option .fromRecord { name: " Pat " , title: " Dr. " }) )
113
80
" {\" title\" :\" Dr.\" ,\" name\" :\" Pat\" }"
0 commit comments