import * as Validation from './validation';

describe('Validation Helper', () => {
  test('isRequired()', () => {
    expect(Validation.isRequired('')).toEqual('empty');
    expect(Validation.isRequired('', false)).toBe(false);
    expect(Validation.isRequired('some string')).toBe(true);
  });

  test('validateString()', () => {
    expect(Validation.validateString(2)).toEqual('not_string');
    expect(Validation.validateString(true, false, false)).toBe(false);
    expect(Validation.validateString('', true, true)).toEqual('empty');
    expect(Validation.validateString([], true, false)).toBe(false);
    expect(Validation.validateString('some string', true, true)).toBe(true);
  });

  test('validateEmail()', () => {
    expect(Validation.validateEmail(2)).toEqual('not_string');
    expect(Validation.validateEmail(true, false, false)).toBe(false);
    expect(Validation.validateEmail('', true, true)).toEqual('empty');
    expect(Validation.validateEmail({}, true, false)).toBe(false);
    expect(Validation.validateEmail('mm@gig', true, true)).toEqual('not_email');
    expect(Validation.validateEmail('mohsen@gmail.com', true, true)).toBe(true);
  });
});
