Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
import React from 'react';
import { mount } from 'enzyme';
import LimitIndicator from '../../MultiEmailSelect/LimitIndicator';

describe('MultiEmailSelect LimitIndicator', () => {
  let component;
  const mockGetValue = jest.fn();

  it('matches a snapshot', () => {
    mockGetValue.mockReturnValue(new Array(5));
    const selectProps = {
      emailsLimit: 10,
    };
    component = mount(<LimitIndicator getValue={mockGetValue} selectProps={selectProps} />);
    expect(component.getElement()).toMatchSnapshot();
  });
  it('it renders the indicator if the threshold is reached', () => {
    mockGetValue.mockReturnValue(new Array(95));
    const selectProps = {
      emailsLimit: 100,
    };
    component = mount(<LimitIndicator getValue={mockGetValue} selectProps={selectProps} />);
    expect(component.find('.MultiEmailSelect__limit-indicator').exists()).toBeTruthy();
  });
  it('it does not render the indicator if the threshold is not reached', () => {
    mockGetValue.mockReturnValue(new Array(50));
    const selectProps = {
      emailsLimit: 100,
    };
    component = mount(<LimitIndicator getValue={mockGetValue} selectProps={selectProps} />);
    expect(component.find('.MultiEmailSelect__limit-indicator').exists()).toBeFalsy();
  });
});