@@ -74,43 +74,43 @@ defmodule Scenic.ThemesTest do
74
74
assert Themes . normalize ( :dark ) == @ theme_dark
75
75
end
76
76
77
- test "custom validate method accepts custom named themes" do
78
- assert Themes . validate ( { :custom_scenic , :custom_dark } ) == { :ok , { :custom_scenic , :custom_dark } }
79
- assert Themes . validate ( { :custom_scenic , :custom_light } ) == { :ok , { :custom_scenic , :custom_light } }
80
- assert Themes . validate ( { :custom_scenic , :custom_primary } ) == { :ok , { :custom_scenic , :custom_primary } }
81
- assert Themes . validate ( { :custom_scenic , :custom_secondary } ) == { :ok , { :custom_scenic , :custom_secondary } }
82
- assert Themes . validate ( { :custom_scenic , :custom_success } ) == { :ok , { :custom_scenic , :custom_success } }
83
- assert Themes . validate ( { :custom_scenic , :custom_danger } ) == { :ok , { :custom_scenic , :custom_danger } }
84
- assert Themes . validate ( { :custom_scenic , :custom_warning } ) == { :ok , { :custom_scenic , :custom_warning } }
85
- assert Themes . validate ( { :custom_scenic , :custom_info } ) == { :ok , { :custom_scenic , :custom_info } }
86
- assert Themes . validate ( { :custom_scenic , :custom_text } ) == { :ok , { :custom_scenic , :custom_text } }
77
+ test "custom validate! method accepts custom named themes" do
78
+ assert Themes . validate! ( { :custom_scenic , :custom_dark } ) == { :ok , { :custom_scenic , :custom_dark } }
79
+ assert Themes . validate! ( { :custom_scenic , :custom_light } ) == { :ok , { :custom_scenic , :custom_light } }
80
+ assert Themes . validate! ( { :custom_scenic , :custom_primary } ) == { :ok , { :custom_scenic , :custom_primary } }
81
+ assert Themes . validate! ( { :custom_scenic , :custom_secondary } ) == { :ok , { :custom_scenic , :custom_secondary } }
82
+ assert Themes . validate! ( { :custom_scenic , :custom_success } ) == { :ok , { :custom_scenic , :custom_success } }
83
+ assert Themes . validate! ( { :custom_scenic , :custom_danger } ) == { :ok , { :custom_scenic , :custom_danger } }
84
+ assert Themes . validate! ( { :custom_scenic , :custom_warning } ) == { :ok , { :custom_scenic , :custom_warning } }
85
+ assert Themes . validate! ( { :custom_scenic , :custom_info } ) == { :ok , { :custom_scenic , :custom_info } }
86
+ assert Themes . validate! ( { :custom_scenic , :custom_text } ) == { :ok , { :custom_scenic , :custom_text } }
87
87
end
88
88
89
89
test "custom validate method rejects map without custom standard color" do
90
- { :error , msg } = Themes . validate ( { :custom_scenic , :custom_invalid } )
90
+ { :error , msg } = Themes . validate! ( { :custom_scenic , :custom_invalid } )
91
91
assert msg =~ "Invalid theme specification"
92
92
assert msg =~ "Map entry: :surface"
93
93
end
94
94
95
95
test "validate accepts the named themes" do
96
- assert Themes . validate ( { :scenic , :dark } ) == { :ok , { :scenic , :dark } }
97
- assert Themes . validate ( { :scenic , :light } ) == { :ok , { :scenic , :light } }
98
- assert Themes . validate ( { :scenic , :primary } ) == { :ok , { :scenic , :primary } }
99
- assert Themes . validate ( { :scenic , :secondary } ) == { :ok , { :scenic , :secondary } }
100
- assert Themes . validate ( { :scenic , :success } ) == { :ok , { :scenic , :success } }
101
- assert Themes . validate ( { :scenic , :danger } ) == { :ok , { :scenic , :danger } }
102
- assert Themes . validate ( { :scenic , :warning } ) == { :ok , { :scenic , :warning } }
103
- assert Themes . validate ( { :scenic , :info } ) == { :ok , { :scenic , :info } }
104
- assert Themes . validate ( { :scenic , :text } ) == { :ok , { :scenic , :text } }
96
+ assert Themes . validate! ( { :scenic , :dark } ) == { :ok , { :scenic , :dark } }
97
+ assert Themes . validate! ( { :scenic , :light } ) == { :ok , { :scenic , :light } }
98
+ assert Themes . validate! ( { :scenic , :primary } ) == { :ok , { :scenic , :primary } }
99
+ assert Themes . validate! ( { :scenic , :secondary } ) == { :ok , { :scenic , :secondary } }
100
+ assert Themes . validate! ( { :scenic , :success } ) == { :ok , { :scenic , :success } }
101
+ assert Themes . validate! ( { :scenic , :danger } ) == { :ok , { :scenic , :danger } }
102
+ assert Themes . validate! ( { :scenic , :warning } ) == { :ok , { :scenic , :warning } }
103
+ assert Themes . validate! ( { :scenic , :info } ) == { :ok , { :scenic , :info } }
104
+ assert Themes . validate! ( { :scenic , :text } ) == { :ok , { :scenic , :text } }
105
105
end
106
106
107
107
test "validate rejects invalid theme names" do
108
- { :error , msg } = Themes . validate ( :invalid )
108
+ { :error , msg } = Themes . validate! ( :invalid )
109
109
assert msg =~ "The theme could not be found in library"
110
110
end
111
111
112
112
test "validate defaults to the scenic library when an atom is passed" do
113
- assert Themes . validate ( :primary ) == { :ok , :primary }
113
+ assert Themes . validate! ( :primary ) == { :ok , :primary }
114
114
end
115
115
116
116
test "validate accepts maps of colors" do
@@ -124,7 +124,7 @@ defmodule Scenic.ThemesTest do
124
124
my_color: :black
125
125
}
126
126
127
- assert Themes . validate ( color_map ) == { :ok , color_map }
127
+ assert Themes . validate! ( color_map ) == { :ok , color_map }
128
128
end
129
129
130
130
test "validate rejects maps with invalid colors" do
@@ -138,19 +138,23 @@ defmodule Scenic.ThemesTest do
138
138
my_color: :black
139
139
}
140
140
141
- { :error , msg } = Themes . validate ( color_map )
141
+ { :error , msg } = Themes . validate! ( color_map )
142
142
assert msg =~ "Map entry: :border"
143
143
assert msg =~ "Invalid Color specification: :invalid"
144
144
end
145
145
146
- test "verify rejects maps without the standard colors" do
146
+ test "validate! rejects maps without the standard colors" do
147
147
color_map = % { some_name: :red }
148
- { :error , msg } = Themes . validate ( color_map )
148
+ { :error , msg } = Themes . validate! ( color_map )
149
149
assert msg =~ "didn't include all the required color"
150
150
end
151
151
152
- test "verify rejects invalid values" do
153
- { :error , _msg } = Themes . validate ( "totally wrong" )
152
+ test "validate rejects invalid values" do
153
+ { :error , _msg } = Themes . validate! ( "totally wrong" )
154
+ end
155
+
156
+ test "validate rejects invalid values and does not raise" do
157
+ { :error , :invalid } = Themes . validate ( "totally wrong" )
154
158
end
155
159
156
160
@ default_schema [ :text , :background , :border , :active , :thumb , :focus ]
0 commit comments