import { TaskActionTypes } from '../../models';
import { isTaskType } from './is-task-type.helper';

describe('isTaskType', () => {
  describe('OK type matching', () => {
    it('should return true when comparing OK with OK', () => {
      expect(isTaskType('OK', TaskActionTypes.OK)).toBe(true);
    });

    it('should return true when comparing RETOURE_OK with OK', () => {
      expect(isTaskType('RETOURE_OK', TaskActionTypes.OK)).toBe(true);
    });

    it('should return true when comparing OK with RETOURE_OK', () => {
      expect(isTaskType('OK', TaskActionTypes.RETOURE_OK)).toBe(true);
    });

    it('should return true when comparing RETOURE_OK with RETOURE_OK', () => {
      expect(isTaskType('RETOURE_OK', TaskActionTypes.RETOURE_OK)).toBe(true);
    });
  });

  describe('NOK type matching', () => {
    it('should return true when comparing NOK with NOK', () => {
      expect(isTaskType('NOK', TaskActionTypes.NOK)).toBe(true);
    });

    it('should return true when comparing RETOURE_NOK with NOK', () => {
      expect(isTaskType('RETOURE_NOK', TaskActionTypes.NOK)).toBe(true);
    });

    it('should return true when comparing NOK with RETOURE_NOK', () => {
      expect(isTaskType('NOK', TaskActionTypes.RETOURE_NOK)).toBe(true);
    });

    it('should return true when comparing RETOURE_NOK with RETOURE_NOK', () => {
      expect(isTaskType('RETOURE_NOK', TaskActionTypes.RETOURE_NOK)).toBe(true);
    });
  });

  describe('UNKNOWN type matching', () => {
    it('should return true when comparing UNKNOWN with UNKNOWN', () => {
      expect(isTaskType('UNKNOWN', TaskActionTypes.UNKNOWN)).toBe(true);
    });

    it('should return true when comparing RETOURE_UNKNOWN with UNKNOWN', () => {
      expect(isTaskType('RETOURE_UNKNOWN', TaskActionTypes.UNKNOWN)).toBe(true);
    });

    it('should return true when comparing UNKNOWN with RETOURE_UNKNOWN', () => {
      expect(isTaskType('UNKNOWN', TaskActionTypes.RETOURE_UNKNOWN)).toBe(true);
    });

    it('should return true when comparing RETOURE_UNKNOWN with RETOURE_UNKNOWN', () => {
      expect(
        isTaskType('RETOURE_UNKNOWN', TaskActionTypes.RETOURE_UNKNOWN),
      ).toBe(true);
    });
  });

  describe('non-matching types', () => {
    it('should return false when comparing OK with NOK', () => {
      expect(isTaskType('OK', TaskActionTypes.NOK)).toBe(false);
    });

    it('should return false when comparing RETOURE_OK with UNKNOWN', () => {
      expect(isTaskType('RETOURE_OK', TaskActionTypes.UNKNOWN)).toBe(false);
    });

    it('should return false when comparing NOK with OK', () => {
      expect(isTaskType('NOK', TaskActionTypes.OK)).toBe(false);
    });
  });

  describe('falsy values', () => {
    it('should return false when value is undefined', () => {
      expect(isTaskType(undefined, TaskActionTypes.OK)).toBe(false);
    });

    it('should return false when value is null', () => {
      expect(isTaskType(null, TaskActionTypes.OK)).toBe(false);
    });

    it('should return false when value is empty string', () => {
      expect(isTaskType('', TaskActionTypes.OK)).toBe(false);
    });
  });
});
