@@ -74,43 +74,43 @@ defmodule Scenic.ThemesTest do
7474 assert Themes . normalize ( :dark ) == @ theme_dark
7575 end
7676
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 } }
8787 end
8888
8989 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 } )
9191 assert msg =~ "Invalid theme specification"
9292 assert msg =~ "Map entry: :surface"
9393 end
9494
9595 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 } }
105105 end
106106
107107 test "validate rejects invalid theme names" do
108- { :error , msg } = Themes . validate ( :invalid )
108+ { :error , msg } = Themes . validate! ( :invalid )
109109 assert msg =~ "The theme could not be found in library"
110110 end
111111
112112 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 }
114114 end
115115
116116 test "validate accepts maps of colors" do
@@ -124,7 +124,7 @@ defmodule Scenic.ThemesTest do
124124 my_color: :black
125125 }
126126
127- assert Themes . validate ( color_map ) == { :ok , color_map }
127+ assert Themes . validate! ( color_map ) == { :ok , color_map }
128128 end
129129
130130 test "validate rejects maps with invalid colors" do
@@ -138,19 +138,23 @@ defmodule Scenic.ThemesTest do
138138 my_color: :black
139139 }
140140
141- { :error , msg } = Themes . validate ( color_map )
141+ { :error , msg } = Themes . validate! ( color_map )
142142 assert msg =~ "Map entry: :border"
143143 assert msg =~ "Invalid Color specification: :invalid"
144144 end
145145
146- test "verify rejects maps without the standard colors" do
146+ test "validate! rejects maps without the standard colors" do
147147 color_map = % { some_name: :red }
148- { :error , msg } = Themes . validate ( color_map )
148+ { :error , msg } = Themes . validate! ( color_map )
149149 assert msg =~ "didn't include all the required color"
150150 end
151151
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" )
154158 end
155159
156160 @ default_schema [ :text , :background , :border , :active , :thumb , :focus ]
0 commit comments