Repository URL to install this package:
|
Version:
4.1.4 ▾
|
@doodle/components
/
src
/
components
/
controls
/
Input
/
__tests__
/
MultiEmailSelect
/
LimitIndicator.sepc.js
|
|---|
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();
});
});