import { MOCK } from '../MOCK';
import { prepareDataBeforeSubmit } from '../helpers';
import { TRotationSettingSubmit } from '../types';

describe('Подготовка данных перед отправкой на бэк', () => {
  test('Ротация отключена', () => {
    expect(
      prepareDataBeforeSubmit(MOCK.disabledRotation as TRotationSettingSubmit),
    ).toEqual({ rotation_type: 2 });
  });
  test('Тип ротации - размер,  правильные данные', () => {
    expect(
      prepareDataBeforeSubmit(
        MOCK.currentTypeOfSizeRotation as TRotationSettingSubmit,
      ),
    ).toEqual({ rotation_type: 1, size_rotation: 123 });
  });
  test('Тип ротации - размер, нулевое значение', () => {
    expect(
      prepareDataBeforeSubmit(
        MOCK.currentRotationAndCurrentType as TRotationSettingSubmit,
      ),
    ).toEqual({ rotation_type: 1, size_rotation: 0 });
  });
  test('Тип ротации - время, правильное время', () => {
    expect(
      prepareDataBeforeSubmit(
        MOCK.currentTypeOfTimeRotation as TRotationSettingSubmit,
      ),
    ).toEqual({ rotation_type: 0, schedule: { period: 'day', time: '01:00' } });
  });
  test('Тип ротации - неделя', () => {
    expect(
      prepareDataBeforeSubmit(
        MOCK.currentTypeOfWeekRotation as unknown as TRotationSettingSubmit,
      ),
    ).toEqual({
      rotation_type: 0,
      schedule: {
        period: 'week',
        week_day: ['tuesday'],
      },
    });
  });
  test('Тип ротации - месяц', () => {
    expect(
      prepareDataBeforeSubmit(
        MOCK.currentTypeOfMonthRotation as unknown as TRotationSettingSubmit,
      ),
    ).toEqual({
      rotation_type: 0,
      schedule: {
        period: 'month',
        week_day: ['january'],
      },
    });
  });
});
