package helper

import (
	"testing"
	"time"
)

func TestGetShiftDates(t *testing.T) {
	// First case 1: First shift
	inputTime := time.Date(2023, 1, 15, 7, 0, 0, 0, time.UTC)
	expectedStart := time.Date(2023, 1, 15, 6, 0, 0, 0, time.UTC)
	expectedEnd := time.Date(2023, 1, 15, 14, 0, 0, 0, time.UTC)
	shifts, err := GetShiftDates(inputTime)
	if err != nil {
		t.Errorf("unexpected error GetShiftDates: %v", err)
	}
	if shifts[0] != expectedStart || shifts[1] != expectedEnd {
		t.Errorf("not expected results: got %v, %v; want %v, %v", shifts[0], shifts[1], expectedStart, expectedEnd)
	}
	// Second case 1: Second shift
	inputTime = time.Date(2023, 1, 15, 14, 0, 0, 0, time.UTC)
	expectedStart = time.Date(2023, 1, 15, 14, 0, 0, 0, time.UTC)
	expectedEnd = time.Date(2023, 1, 15, 22, 0, 0, 0, time.UTC)
	shifts, err = GetShiftDates(inputTime)
	if err != nil {
		t.Errorf("unexpected error GetShiftDates: %v", err)
	}
	if shifts[0] != expectedStart || shifts[1] != expectedEnd {
		t.Errorf("not expected results: got %v, %v; want %v, %v", shifts[0], shifts[1], expectedStart, expectedEnd)
	}
	// Third case 3: Third shift
	inputTime = time.Date(2023, 1, 15, 23, 0, 0, 0, time.UTC)
	expectedStart = time.Date(2023, 1, 15, 22, 0, 0, 0, time.UTC)
	expectedEnd = time.Date(2023, 1, 16, 6, 0, 0, 0, time.UTC)
	shifts, err = GetShiftDates(inputTime)
	if err != nil {
		t.Errorf("unexpected error GetShiftDates: %v", err)
	}
	if shifts[0] != expectedStart || shifts[1] != expectedEnd {
		t.Errorf("not expected results: got %v, %v; want %v, %v", shifts[0], shifts[1], expectedStart, expectedEnd)
	}
}
