package core

import "testing"

func TestCronExplain(t *testing.T) {
	tests := []struct {
		name  string
		input string
		want  string
	}{
		{"every 15 minutes", "*/15 * * * *", "every 15 minutes"},
		{"daily at 00:00", "0 0 * * *", "daily at 00:00"},
		{"weekdays at 09:00", "0 9 * * 1-5", "weekdays at 09:00"},
		{"every 30 minutes", "*/30 * * * *", "every 30 minutes"},
		{"every 2 hours", "0 */2 * * *", "every 2 hours"},
		{"shortcut @hourly", "@hourly", "hourly"},
		{"shortcut @daily", "@daily", "daily"},
		{"shortcut @weekly", "@weekly", "weekly"},
		{"shortcut @monthly", "@monthly", "monthly"},
		{"unknown returns raw", "5 4 * * 0", "5 4 * * 0"},
		{"invalid too few fields", "bad", "bad"},
		{"every minute", "*/1 * * * *", "every minute"},
		{"daily at 14:30", "30 14 * * *", "daily at 14:30"},
		{"every hour zero min", "0 */1 * * *", "every hour"},
		{"shortcut @midnight", "@midnight", "daily"},
		{"weekdays at 08:00", "0 8 * * 1-5", "weekdays at 08:00"},
	}

	for _, tc := range tests {
		t.Run(tc.name, func(t *testing.T) {
			got := CronExplain(tc.input)
			if got != tc.want {
				t.Errorf("CronExplain(%q) = %q, want %q", tc.input, got, tc.want)
			}
		})
	}
}
