@@ -182,6 +182,125 @@ func TestValidatePokemonArgs(t *testing.T) {
182182 }
183183}
184184
185+ // TestValidateBerryArgs tests the ValidateBerryArgs function
186+ func TestValidateBerryArgs (t * testing.T ) {
187+ validInputs := [][]string {
188+ {"poke-cli" , "berry" },
189+ {"poke-cli" , "berry" , "--help" },
190+ }
191+
192+ for _ , input := range validInputs {
193+ err := ValidateBerryArgs (input )
194+ require .NoError (t , err , "Expected no error for valid input" )
195+ }
196+
197+ invalidInputs := [][]string {
198+ {"poke-cli" , "berry" , "oran" },
199+ }
200+
201+ for _ , input := range invalidInputs {
202+ err := ValidateBerryArgs (input )
203+ require .Error (t , err , "Expected error for invalid input" )
204+ }
205+
206+ tooManyArgs := [][]string {
207+ {"poke-cli" , "berry" , "oran" , "sitrus" },
208+ }
209+
210+ expectedError := styling .StripANSI ("╭──────────────────╮\n │✖ Error! │\n │Too many arguments│\n ╰──────────────────╯" )
211+
212+ for _ , input := range tooManyArgs {
213+ err := ValidateBerryArgs (input )
214+
215+ if err == nil {
216+ t .Fatalf ("Expected an error for input %v, but got nil" , input )
217+ }
218+
219+ strippedErr := styling .StripANSI (err .Error ())
220+ assert .Equal (t , expectedError , strippedErr , "Unexpected error message for invalid input" )
221+ }
222+ }
223+
224+ // TestValidateItemArgs tests the ValidateItemArgs function
225+ func TestValidateItemArgs (t * testing.T ) {
226+ validInputs := [][]string {
227+ {"poke-cli" , "item" , "--help" },
228+ {"poke-cli" , "item" , "potion" },
229+ {"poke-cli" , "item" , "master-ball" },
230+ }
231+
232+ for _ , input := range validInputs {
233+ err := ValidateItemArgs (input )
234+ require .NoError (t , err , "Expected no error for valid input" )
235+ }
236+
237+ invalidInputs := [][]string {
238+ {"poke-cli" , "item" },
239+ }
240+
241+ for _ , input := range invalidInputs {
242+ err := ValidateItemArgs (input )
243+ require .Error (t , err , "Expected error for invalid input" )
244+ }
245+
246+ tooManyArgs := [][]string {
247+ {"poke-cli" , "item" , "potion" , "super-potion" },
248+ }
249+
250+ expectedError := styling .StripANSI ("╭──────────────────╮\n │✖ Error! │\n │Too many arguments│\n ╰──────────────────╯" )
251+
252+ for _ , input := range tooManyArgs {
253+ err := ValidateItemArgs (input )
254+
255+ if err == nil {
256+ t .Fatalf ("Expected an error for input %v, but got nil" , input )
257+ }
258+
259+ strippedErr := styling .StripANSI (err .Error ())
260+ assert .Equal (t , expectedError , strippedErr , "Unexpected error message for invalid input" )
261+ }
262+ }
263+
264+ // TestValidateMoveArgs tests the ValidateMoveArgs function
265+ func TestValidateMoveArgs (t * testing.T ) {
266+ validInputs := [][]string {
267+ {"poke-cli" , "move" , "--help" },
268+ {"poke-cli" , "move" , "thunderbolt" },
269+ {"poke-cli" , "move" , "Dragon-Tail" },
270+ }
271+
272+ for _ , input := range validInputs {
273+ err := ValidateMoveArgs (input )
274+ require .NoError (t , err , "Expected no error for valid input" )
275+ }
276+
277+ invalidInputs := [][]string {
278+ {"poke-cli" , "move" },
279+ }
280+
281+ for _ , input := range invalidInputs {
282+ err := ValidateMoveArgs (input )
283+ require .Error (t , err , "Expected error for invalid input" )
284+ }
285+
286+ tooManyArgs := [][]string {
287+ {"poke-cli" , "move" , "tackle" , "scratch" },
288+ }
289+
290+ expectedError := styling .StripANSI ("╭──────────────────╮\n │✖ Error! │\n │Too many arguments│\n ╰──────────────────╯" )
291+
292+ for _ , input := range tooManyArgs {
293+ err := ValidateMoveArgs (input )
294+
295+ if err == nil {
296+ t .Fatalf ("Expected an error for input %v, but got nil" , input )
297+ }
298+
299+ strippedErr := styling .StripANSI (err .Error ())
300+ assert .Equal (t , expectedError , strippedErr , "Unexpected error message for invalid input" )
301+ }
302+ }
303+
185304// TestValidateSearchArgs tests the ValidateSearchArgs function
186305func TestValidateSearchArgs (t * testing.T ) {
187306 validInputs := [][]string {
@@ -262,3 +381,42 @@ func TestValidateTypesArgs(t *testing.T) {
262381 assert .Equal (t , expectedError , strippedErr , "Unexpected error message for invalid input" )
263382 }
264383}
384+
385+ // TestValidateSpeedArgs tests the ValidateSpeedArgs function
386+ func TestValidateSpeedArgs (t * testing.T ) {
387+ validInputs := [][]string {
388+ {"poke-cli" , "speed" },
389+ {"poke-cli" , "speed" , "--help" },
390+ }
391+
392+ for _ , input := range validInputs {
393+ err := ValidateSpeedArgs (input )
394+ require .NoError (t , err , "Expected no error for valid input" )
395+ }
396+
397+ invalidInputs := [][]string {
398+ {"poke-cli" , "speed" , "100" },
399+ }
400+
401+ for _ , input := range invalidInputs {
402+ err := ValidateSpeedArgs (input )
403+ require .Error (t , err , "Expected error for invalid input" )
404+ }
405+
406+ tooManyArgs := [][]string {
407+ {"poke-cli" , "speed" , "100" , "200" },
408+ }
409+
410+ expectedError := styling .StripANSI ("╭──────────────────╮\n │✖ Error! │\n │Too many arguments│\n ╰──────────────────╯" )
411+
412+ for _ , input := range tooManyArgs {
413+ err := ValidateSpeedArgs (input )
414+
415+ if err == nil {
416+ t .Fatalf ("Expected an error for input %v, but got nil" , input )
417+ }
418+
419+ strippedErr := styling .StripANSI (err .Error ())
420+ assert .Equal (t , expectedError , strippedErr , "Unexpected error message for invalid input" )
421+ }
422+ }
0 commit comments