import React from 'react';
import '@testing-library/jest-dom';
import { render } from '@testing-library/react-native';
import { IGobalHeaderProps, OrganismGlobalHeader } from './index';

describe('[Native] GlobalHeader', () => {
  const props: IGobalHeaderProps = {
    isAvailable: true,
    logged: false,
    type: 'mobile',
    iconName: 'tier_bronze',
    actualPoints: 0,
    actualTier: '',
    nextPoints: 0,
    nextTier: '',
    userName: '',
    greetings: '',
    logoTheme: 'light',
  };

  it('render component', () => {
    const component = render(<OrganismGlobalHeader {...props} />);
    expect(component).toBeTruthy();
  });

  it('render according to zipcode', () => {
    const component = render(<OrganismGlobalHeader {...props} />);
    expect(component).toBeTruthy();
    expect(props.isAvailable).toBeTruthy();
  });

  it('render according to zipcode', () => {
    const props: IGobalHeaderProps = {
      isAvailable: false,
      logged: false,
      type: 'mobile',
      iconName: 'tier_bronze',
      actualPoints: 0,
      actualTier: '',
      nextPoints: 0,
      nextTier: '',
      userName: '',
      greetings: '',
      logoTheme: 'light',
    };
    const component = render(<OrganismGlobalHeader {...props} />);
    expect(component).toBeTruthy();
    expect(props.isAvailable).toBeFalsy();
  });

  it('render logged container', () => {
    const props: IGobalHeaderProps = {
      isAvailable: true,
      logged: true,
      type: 'mobile',
      iconName: 'tier_bronze',
      actualPoints: 0,
      actualTier: '',
      nextPoints: 0,
      nextTier: '',
      userName: '',
      greetings: '',
      logoTheme: 'light',
    };
    const component = render(<OrganismGlobalHeader {...props} />);

    const element = component.getByTestId('loggedContainer');

    expect(element).toBeDefined();
  });

  it('render not logged container', () => {
    const props: IGobalHeaderProps = {
      isAvailable: true,
      logged: false,
      type: 'mobile',
      iconName: 'tier_bronze',
      actualPoints: 0,
      actualTier: '',
      nextPoints: 0,
      nextTier: '',
      userName: '',
      greetings: '',
      logoTheme: 'light',
    };
    const component = render(<OrganismGlobalHeader {...props} />);

    const element = component.getByTestId('notLoggedContainer');

    expect(element).toBeDefined();
  });

  it('render all props', () => {
    const props: IGobalHeaderProps = {
      isAvailable: true,
      logged: true,
      actualPoints: 1000,
      actualTier: 'Silver Tier',
      nextPoints: 1000,
      nextTier: 'pts to Silver',
      iconName: 'tier_bronze',
      userName: 'Thomas',
      type: 'mobile',
      greetings: 'Hello',
      logoTheme: 'light',
    };

    const component = render(<OrganismGlobalHeader {...props} />);

    expect(component).toBeTruthy();
    expect(props).toBeTruthy();
    expect(props).toBeDefined();
    expect(props.userName).toBeDefined();
  });
  it('render all props except logoTheme', () => {
    const props: IGobalHeaderProps = {
      isAvailable: true,
      logged: true,
      actualPoints: 1000,
      actualTier: 'Silver Tier',
      nextPoints: 1000,
      nextTier: 'pts to Silver',
      iconName: 'tier_bronze',
      userName: 'Thomas',
      type: 'mobile',
      greetings: 'Hello',
      logoTheme: 'light',
    };

    const component = render(<OrganismGlobalHeader {...props} />);

    expect(component).toBeTruthy();
    expect(props).toBeTruthy();
    expect(props).toBeDefined();
    expect(props.userName).toBeDefined();
  });

  it('render all props with isAvailable false', () => {
    const props: IGobalHeaderProps = {
      isAvailable: false,
      logged: true,
      actualPoints: 1000,
      actualTier: 'Silver Tier',
      nextPoints: 1000,
      nextTier: 'pts to Silver',
      iconName: 'tier_bronze',
      userName: 'Thomas',
      type: 'mobile',
      greetings: 'Hello',
      logoTheme: 'light',
    };

    const component = render(<OrganismGlobalHeader {...props} />);

    expect(component).toBeTruthy();
    expect(props).toBeTruthy();
    expect(props).toBeDefined();
    expect(props.userName).toBeDefined();
  });
});
