Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into summary-files-fix
- Loading branch information
Showing
20 changed files
with
1,179 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import React from 'react' | ||
import { TokenDecimals } from './TokenDecimals' | ||
import { Form } from 'react-final-form' | ||
import Adapter from 'enzyme-adapter-react-15' | ||
import { configure, mount, shallow } from 'enzyme' | ||
import { VALIDATION_MESSAGES } from '../../utils/constants' | ||
|
||
configure({ adapter: new Adapter() }) | ||
|
||
describe('TokenDecimals', () => { | ||
it(`should render TokenDecimals component`, () => { | ||
const wrapper = shallow( | ||
<Form onSubmit={jest.fn()} component={TokenDecimals} errorStyle={{ color: 'red', fontWeight: 'bold', }}/> | ||
) | ||
expect(wrapper).toMatchSnapshot() | ||
}) | ||
|
||
it(`should render TokenDecimals component and its children`, () => { | ||
const wrapper = mount( | ||
<Form onSubmit={jest.fn()} component={TokenDecimals} errorStyle={{ color: 'red', fontWeight: 'bold', }}/> | ||
) | ||
expect(wrapper).toMatchSnapshot() | ||
}) | ||
|
||
it(`should render TokenDecimals component and its children, with input field disabled`, () => { | ||
const wrapper = mount( | ||
<Form | ||
onSubmit={jest.fn()} | ||
component={TokenDecimals} | ||
errorStyle={{ color: 'red', fontWeight: 'bold', }} | ||
disabled={true} | ||
/> | ||
) | ||
expect(wrapper).toMatchSnapshot() | ||
}) | ||
|
||
it(`should give error if decimals is empty`, () => { | ||
const wrapper = mount( | ||
<Form onSubmit={jest.fn()} component={TokenDecimals} errorStyle={{ color: 'red', fontWeight: 'bold', }}/> | ||
) | ||
|
||
const input = wrapper.find('input[name="decimals"]') | ||
|
||
input.simulate('change', { target: { value: '10' } }) | ||
expect(wrapper.find('InputField2').prop('meta').error).toBeFalsy() | ||
|
||
input.simulate('change', { target: { value: '' } }) | ||
expect(wrapper.find('InputField2').prop('meta').error).toBe(VALIDATION_MESSAGES.REQUIRED) | ||
}) | ||
|
||
it(`should give error if decimals is greater than 18`, () => { | ||
const wrapper = mount( | ||
<Form onSubmit={jest.fn()} component={TokenDecimals} errorStyle={{ color: 'red', fontWeight: 'bold', }}/> | ||
) | ||
const input = wrapper.find('input[name="decimals"]') | ||
input.simulate('change', { target: { value: '21' } }) | ||
|
||
expect(wrapper.find('.error').text()).toBe('Should not be greater than 18') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import React from 'react' | ||
import { TokenName } from './TokenName' | ||
import { Form } from 'react-final-form' | ||
import Adapter from 'enzyme-adapter-react-15' | ||
import { configure, mount, shallow } from 'enzyme' | ||
import { VALIDATION_MESSAGES } from '../../utils/constants' | ||
|
||
configure({ adapter: new Adapter() }) | ||
|
||
describe('TokenName', () => { | ||
it(`should render TokenName component`, () => { | ||
const wrapper = shallow( | ||
<Form onSubmit={jest.fn()} component={TokenName} errorStyle={{ color: 'red', fontWeight: 'bold', }}/> | ||
) | ||
expect(wrapper).toMatchSnapshot() | ||
}) | ||
|
||
it(`should render TokenName component and its children`, () => { | ||
const wrapper = mount( | ||
<Form onSubmit={jest.fn()} component={TokenName} errorStyle={{ color: 'red', fontWeight: 'bold', }}/> | ||
) | ||
expect(wrapper).toMatchSnapshot() | ||
}) | ||
|
||
it(`should give error if name is only spaces`, () => { | ||
const wrapper = mount( | ||
<Form onSubmit={jest.fn()} component={TokenName} errorStyle={{ color: 'red', fontWeight: 'bold', }}/> | ||
) | ||
const input = wrapper.find('input[name="name"]') | ||
input.simulate('change', { target: { value: ' ' } }) | ||
|
||
expect(wrapper.find('.error').text()).toBe('Name should have at least one character') | ||
}) | ||
|
||
it(`should give error if name is empty`, () => { | ||
const wrapper = mount( | ||
<Form onSubmit={jest.fn()} component={TokenName} errorStyle={{ color: 'red', fontWeight: 'bold', }}/> | ||
) | ||
|
||
const input = wrapper.find('input[name="name"]') | ||
|
||
input.simulate('change', { target: { value: 'valid name' } }) | ||
expect(wrapper.find('InputField2').prop('meta').error).toBeFalsy() | ||
|
||
input.simulate('change', { target: { value: '' } }) | ||
expect(wrapper.find('InputField2').prop('meta').error).toBe(VALIDATION_MESSAGES.REQUIRED) | ||
}) | ||
|
||
it(`should give error if name is longer than 30 characters`, () => { | ||
const wrapper = mount( | ||
<Form onSubmit={jest.fn()} component={TokenName} errorStyle={{ color: 'red', fontWeight: 'bold', }}/> | ||
) | ||
const input = wrapper.find('input[name="name"]') | ||
input.simulate('change', { target: { value: '1234567890132546789012345678901' } }) | ||
|
||
expect(wrapper.find('.error').text()).toBe(VALIDATION_MESSAGES.NAME) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import React from 'react' | ||
import { TokenTicker } from './TokenTicker' | ||
import { Form } from 'react-final-form' | ||
import Adapter from 'enzyme-adapter-react-15' | ||
import { configure, mount, shallow } from 'enzyme' | ||
import { VALIDATION_MESSAGES } from '../../utils/constants' | ||
|
||
configure({ adapter: new Adapter() }) | ||
|
||
describe('TokenTicker', () => { | ||
it(`should render TokenTicker component`, () => { | ||
const wrapper = shallow( | ||
<Form onSubmit={jest.fn()} component={TokenTicker} errorStyle={{ color: 'red', fontWeight: 'bold', }}/> | ||
) | ||
expect(wrapper).toMatchSnapshot() | ||
}) | ||
|
||
it(`should render TokenTicker component and its children`, () => { | ||
const wrapper = mount( | ||
<Form onSubmit={jest.fn()} component={TokenTicker} errorStyle={{ color: 'red', fontWeight: 'bold', }}/> | ||
) | ||
expect(wrapper).toMatchSnapshot() | ||
}) | ||
|
||
it(`should give error if ticker name has other than alphanumeric characters`, () => { | ||
const wrapper = mount( | ||
<Form onSubmit={jest.fn()} component={TokenTicker} errorStyle={{ color: 'red', fontWeight: 'bold', }}/> | ||
) | ||
const input = wrapper.find('input[name="ticker"]') | ||
input.simulate('change', { target: { value: 'AB@C8' } }) | ||
|
||
expect(wrapper.find('.error').text()).toBe('Only alphanumeric characters') | ||
}) | ||
|
||
it(`should give error if ticker name is empty`, () => { | ||
const wrapper = mount( | ||
<Form onSubmit={jest.fn()} component={TokenTicker} errorStyle={{ color: 'red', fontWeight: 'bold', }}/> | ||
) | ||
|
||
const input = wrapper.find('input[name="ticker"]') | ||
|
||
input.simulate('change', { target: { value: 'VALID' } }) | ||
expect(wrapper.find('InputField2').prop('meta').error).toBeFalsy() | ||
|
||
input.simulate('change', { target: { value: '' } }) | ||
expect(wrapper.find('InputField2').prop('meta').error).toBe(VALIDATION_MESSAGES.REQUIRED) | ||
}) | ||
|
||
it(`should give error if ticker name is longer than 5 characters`, () => { | ||
const wrapper = mount( | ||
<Form onSubmit={jest.fn()} component={TokenTicker} errorStyle={{ color: 'red', fontWeight: 'bold', }}/> | ||
) | ||
const input = wrapper.find('input[name="ticker"]') | ||
input.simulate('change', { target: { value: '123456' } }) | ||
|
||
expect(wrapper.find('.error').text()).toBe('Please enter a valid ticker between 1-5 characters') | ||
}) | ||
}) |
Oops, something went wrong.