Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

Nazanin/app_2_components_tests_elements #4908

Merged
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
be339b8
add elements tests
nazaninreihani Jan 17, 2019
a984f16
add money.jsx tests
nazaninreihani Jan 17, 2019
c5a4cd1
money.jsx tests
nazaninreihani Jan 18, 2019
f516f1e
Merge branch 'master' into nazanin/app_2_components_tests_elements
nazaninreihani Jan 18, 2019
7da415f
add more tests for elements components
nazaninreihani Jan 18, 2019
2eeab8f
add more tests for elements components
nazaninreihani Jan 18, 2019
5842394
Merge branch 'master' into nazanin/app_2_components_tests_elements
nazaninreihani Jan 31, 2019
30803f2
fixes
nazaninreihani Jan 31, 2019
7e46e39
add more elements tests
nazaninreihani Feb 1, 2019
2581f90
add more elements tests
nazaninreihani Feb 1, 2019
56e8254
Merge branch 'master' into nazanin/app_2_components_tests_elements
nazaninreihani Feb 4, 2019
bdc6e53
Trigger notification
nazaninreihani Feb 4, 2019
953eaa6
fix tests
nazaninreihani Feb 4, 2019
4323deb
Merge branch 'master' into nazanin/app_2_components_tests_elements
nazaninreihani Feb 5, 2019
62bd6c3
Merge branch 'master' into nazanin/app_2_components_tests_elements
nazaninreihani Feb 5, 2019
cc8191d
fix tests
nazaninreihani Feb 5, 2019
f6a1627
add test helper
nazaninreihani Feb 5, 2019
111aea3
Merge branch 'master' into nazanin/app_2_components_tests_elements
ashkanx Feb 6, 2019
11b4a13
test onClick is required in error_box props, camelCase testChildren
nazaninreihani Feb 6, 2019
3f0b79c
Merge remote-tracking branch 'origin/nazanin/app_2_components_tests_e…
nazaninreihani Feb 6, 2019
8e60147
Merge branch 'master' into nazanin/app_2_components_tests_elements
nazaninreihani Feb 12, 2019
ededbeb
fix tests
nazaninreihani Feb 12, 2019
d4162bd
Merge branch 'master' into nazanin/app_2_components_tests_elements
nazaninreihani Feb 15, 2019
2820bc1
Merge branch 'master' into nazanin/app_2_components_tests_elements
nazaninreihani Feb 19, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from 'react';
import { expect } from 'chai';
import { configure, shallow } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import ErrorBox from '../error_box.jsx';

configure({ adapter: new Adapter() });

describe('ErrorBox', () => {
it('should render one <ErrorBox /> component', () => {
const wrapper = shallow(<ErrorBox />);
expect(wrapper).to.have.length(1);
});
it('should render children when passed in', () => {
const child_div = <div className='sweet-child-of-mine' />;
const wrapper = shallow(
<ErrorBox>
{ child_div }
</ErrorBox>
);
expect(wrapper.contains(child_div)).to.equal(true);
});
it('should render header as passed to it', () => {
const wrapper = shallow(<ErrorBox header='This is a header' />);
expect(wrapper.find('.page-error-header').text()).to.be.eql('This is a header');
});
nazaninreihani marked this conversation as resolved.
Show resolved Hide resolved
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react';
import { expect } from 'chai';
import { configure, shallow } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import { EmptyNotification } from '../empty_notification';
import { IconBell } from 'Assets/Header/NavBar';

configure({ adapter: new Adapter() });

describe('Notifications', () => {
it('should render one <EmptyNotification /> component', () => {
const wrapper = shallow(<EmptyNotification />);
expect(wrapper).to.have.length(1);
});
it('should render IconBell', () => {
const wrapper = shallow(<EmptyNotification />);
expect(wrapper.find(IconBell).exists()).to.be.true;
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react';
import { expect } from 'chai';
import { configure, shallow } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import { Notifications } from '../notifications.jsx';
import { EmptyNotification } from '../empty_notification';

configure({ adapter: new Adapter() });

describe('Notifications', () => {
it('should render one <Notifications /> component', () => {
const wrapper = shallow(<Notifications />);
expect(wrapper).to.have.length(1);
});
it('should render .no-notifications-container when the list is not passed', () => {
const wrapper = shallow(<Notifications />);
expect(wrapper.find(EmptyNotification).exists()).to.be.true;
});
it('should not render .no-notifications-container when the list is passed', () => {
const wrapper = shallow(<Notifications list={['First', 'Second', 'Third']} />);
nazaninreihani marked this conversation as resolved.
Show resolved Hide resolved
expect(wrapper.find(EmptyNotification).exists()).to.be.false;
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react';
import { localize } from '_common/localize';
import { IconBell } from 'Assets/Header/NavBar';

const EmptyNotification = () => (
<div className='no-notifications-container'>
<div className='notification-message'>
<div className='bell-icon'>
<IconBell />
</div>
<div>
<h4>{localize('No Notifications')}</h4>
<span className='no-notifications-message'>{localize('You have yet to receive any notifications')}</span>
</div>
</div>
</div>
);

export { EmptyNotification };
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import PropTypes from 'prop-types';
import React from 'react';
import { localize } from '_common/localize';
import { IconBell } from 'Assets/Header/NavBar';
import { DrawerItem } from '../Drawer';
import PropTypes from 'prop-types';
import React from 'react';
import { EmptyNotification } from './empty_notification.jsx';
import { DrawerItem } from '../Drawer';

const Notifications = ({ list }) => (
<React.Fragment>
Expand All @@ -14,24 +13,14 @@ const Notifications = ({ list }) => (
</React.Fragment>
))
:
<div className='no-notifications-container'>
<div className='notification-message'>
<div className='bell-icon'>
<IconBell />
</div>
<div>
<h4>{localize('No Notifications')}</h4>
<span className='no-notifications-message'>{localize('You have yet to receive any notifications')}</span>
</div>
</div>
</div>
<EmptyNotification />
nazaninreihani marked this conversation as resolved.
Show resolved Hide resolved
}

</React.Fragment>
);

Notifications.propTypes = {
'list': PropTypes.object,
list: PropTypes.object,
};

export { Notifications };
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from 'react';
import { expect } from 'chai';
import { configure, shallow } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import LanguageDialog from '../language_dialog.jsx';

configure({ adapter: new Adapter() });

describe('LanguageDialog', () => {
it('should render one <LanguageDialog /> component', () => {
const wrapper = shallow(<LanguageDialog />);
expect(wrapper).to.have.length(1);
});
it('should have .show when is_visible is true and is_settings_on is true', () => {
const wrapper = shallow(<LanguageDialog is_visible={true} is_settings_on={true} />);
expect(wrapper.find('.show').exists()).to.be.true;
});
it('should not have .show when is_visible is true and is_settings_on is false', () => {
const wrapper = shallow(<LanguageDialog is_visible={true} is_settings_on={false} />);
expect(wrapper.find('.show').exists()).to.be.false;
});
it('should not have .show when is_visible is false and is_settings_on is true', () => {
const wrapper = shallow(<LanguageDialog is_visible={false} is_settings_on={true} />);
expect(wrapper.find('.show').exists()).to.be.false;
});
it('should not have .show when is_visible is false and is_settings_on is false', () => {
const wrapper = shallow(<LanguageDialog is_visible={false} is_settings_on={false} />);
expect(wrapper.find('.show').exists()).to.be.false;
});
easteregg marked this conversation as resolved.
Show resolved Hide resolved
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react';
import { expect } from 'chai';
import { configure, shallow } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import SettingsControl from '../settings_control.jsx';

configure({ adapter: new Adapter() });

describe('SettingsControl', () => {
it('should render one <SettingsControl /> component', () => {
const wrapper = shallow(<SettingsControl />);
expect(wrapper).to.have.length(1);
});
it('should render children when passed in', () => {
const child_div = <div className='sweet-child-of-mine' />;
const wrapper = shallow(
<SettingsControl>
{ child_div }
</SettingsControl>
);
expect(wrapper.contains(child_div)).to.equal(true);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from 'react';
import { expect } from 'chai';
import { configure, shallow } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import SettingsDialog from '../settings_dialog.jsx';

configure({ adapter: new Adapter() });

describe('SettingsDialog', () => {
it('should render one <SettingsDialog /> component', () => {
const wrapper = shallow(<SettingsDialog />);
expect(wrapper).to.have.length(1);
});
it('should have .show when is_open is true in props', () => {
const wrapper = shallow(<SettingsDialog is_open={true} />);
expect(wrapper.hasClass('show')).to.be.true;
});
it('should not have .show when is_open is false in props', () => {
const wrapper = shallow(<SettingsDialog is_open={false} />);
expect(wrapper.hasClass('show')).to.be.false;
});
it('should have .hide when is_language_dialog_visible is true in props', () => {
const wrapper = shallow(<SettingsDialog is_language_dialog_visible={true} />);
expect(wrapper.find('.hide').exists()).to.be.true;
});
it('should not have .hide when is_language_dialog_visible is false in props', () => {
const wrapper = shallow(<SettingsDialog is_language_dialog_visible={false} />);
expect(wrapper.find('.hide').exists()).to.be.false;
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react';
import { expect } from 'chai';
import { configure, shallow } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import CloseButton from '../close_button.jsx';

configure({ adapter: new Adapter() });

describe('CloseButton', () => {
it('should render one <CloseButton /> component', () => {
const wrapper = shallow(<CloseButton />);
expect(wrapper).to.have.length(1);
});
});
nazaninreihani marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react';
import { expect } from 'chai';
import { configure, shallow } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import Toast from '../toast.jsx';

configure({ adapter: new Adapter() });

describe('Toast', () => {
it('should render one <Toast /> component', () => {
const wrapper = shallow(<Toast />);
expect(wrapper).to.have.length(1);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react';
import { expect } from 'chai';
import { configure, shallow } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import Transition from '../transition.jsx';

configure({ adapter: new Adapter() });

describe('Transition', () => {
it('should render one <Transition /> component', () => {
const wrapper = shallow(<Transition />);
expect(wrapper).to.have.length(1);
});
it('should render children when passed in', () => {
const child_div = <div className='sweet-child-of-mine' />;
const wrapper = shallow(
<Transition>
{ child_div }
easteregg marked this conversation as resolved.
Show resolved Hide resolved
</Transition>
);
expect(wrapper.contains(child_div)).to.be.true;
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const CloseButton = ({ onClick }) => (
);

CloseButton.propTypes = {
onClick: PropTypes.func,
onClick: PropTypes.func.isRequired,
};

export default CloseButton;
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { shallow } from 'enzyme';
import React from 'react';
import { fake } from 'sinon';
import ToggleButton from '../toggle_button.jsx';
import Button from '../../../Form/button.jsx';
import Button from 'App/Components/Form/button.jsx';

describe('<ToggleButton />', () => {
it('should render a <Button /> element', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React from 'react';
import { expect } from 'chai';
import { configure, shallow } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import Localize from '../localize.jsx';

configure({ adapter: new Adapter() });

describe('Localize', () => {
it('should render one <Localize /> component', () => {
const str = 'something without replacer';
const wrapper = shallow(<Localize str={str} />);
expect(wrapper).to.have.length(1);
});
it('should render with replacers', () => {
const str = 'something with [_1] replacer [_2]';
const replacers = {
'1_2': <a className='a-cool-classname' />,
};
const wrapper = shallow(<Localize str={str} replacers={replacers} />);
expect(wrapper).to.have.length(1);
nazaninreihani marked this conversation as resolved.
Show resolved Hide resolved
expect(wrapper.find('.a-cool-classname').exists()).to.be.true;
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react';
import { expect } from 'chai';
import { configure, shallow } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import LoginPrompt from '../login_prompt.jsx';

configure({ adapter: new Adapter() });

describe('LoginPrompt', () => {
it('should render one <LoginPrompt /> component', () => {
const wrapper = shallow(<LoginPrompt />);
expect(wrapper).to.have.length(1);
});
});
Loading