This commit is contained in:
Guillermo 2018-11-23 22:44:40 -03:00
parent 80b6bcea8a
commit 6596e29d9c
2 changed files with 13 additions and 14 deletions

View File

@ -3,7 +3,7 @@ const TicketInfo = ReactMock();
const Table = ReactMock(); const Table = ReactMock();
const Button = ReactMock(); const Button = ReactMock();
const Tooltip = ReactMock(); const Tooltip = ReactMock();
const Dropdown = ReactMock(); const DepartmentDropdown = ReactMock();
const i18n = stub().returnsArg(0); const i18n = stub().returnsArg(0);
const TicketList = requireUnit('app-components/ticket-list', { const TicketList = requireUnit('app-components/ticket-list', {
@ -11,7 +11,7 @@ const TicketList = requireUnit('app-components/ticket-list', {
'core-components/table': Table, 'core-components/table': Table,
'core-components/button': Button, 'core-components/button': Button,
'core-components/tooltip': Tooltip, 'core-components/tooltip': Tooltip,
'core-components/drop-down': Dropdown, 'app-components/department-dropdown': DepartmentDropdown,
'lib-app/i18n': i18n 'lib-app/i18n': i18n
}); });
@ -54,7 +54,7 @@ describe('TicketList component', function () {
); );
table = TestUtils.scryRenderedComponentsWithType(ticketList, Table); table = TestUtils.scryRenderedComponentsWithType(ticketList, Table);
dropdown = TestUtils.scryRenderedComponentsWithType(ticketList, Dropdown); dropdown = TestUtils.scryRenderedComponentsWithType(ticketList, DepartmentDropdown);
} }
it('should pass correct props to Table', function () { it('should pass correct props to Table', function () {
@ -84,12 +84,12 @@ describe('TicketList component', function () {
} }
]); ]);
}); });
it('should pass loading to Table', function () { it('should pass loading to Table', function () {
renderTicketList({loading: true}); renderTicketList({loading: true});
expect(table[0].props.loading).to.equal(true); expect(table[0].props.loading).to.equal(true);
}); });
it('should pass correct compare function to Table', function () { it('should pass correct compare function to Table', function () {
let minCompare = table[0].props.comp; let minCompare = table[0].props.comp;
@ -114,7 +114,7 @@ describe('TicketList component', function () {
row2.date = '20160401'; row2.date = '20160401';
expect(minCompare(row1, row2)).to.equal(-1); expect(minCompare(row1, row2)).to.equal(-1);
}); });
describe('when using secondary type', function () { describe('when using secondary type', function () {
beforeEach(function () { beforeEach(function () {
renderTicketList({ renderTicketList({
@ -162,10 +162,10 @@ describe('TicketList component', function () {
}); });
it('should pass correct props to dropdown', function () { it('should pass correct props to dropdown', function () {
expect(dropdown[0].props.items).to.deep.equal([ expect(dropdown[0].props.departments).to.deep.equal([
{content: i18n('ALL_DEPARTMENTS')}, {name: i18n('ALL_DEPARTMENTS')},
{content: 'Sales Support'}, {name: 'Sales Support', id: 1},
{content: 'Tech Help'} {name: 'Tech Help', id: 2}
]); ]);
expect(dropdown[0].props.size).to.equal('medium'); expect(dropdown[0].props.size).to.equal('medium');
}); });
@ -185,4 +185,4 @@ describe('TicketList component', function () {
expect(table[0].props.rows.length).to.equal(10); expect(table[0].props.rows.length).to.equal(10);
}); });
}); });
}); });

View File

@ -45,9 +45,8 @@ class TicketList extends React.Component {
render() { render() {
return ( return (
<div className="ticket-list"> <div className="ticket-list">
<div className="ticket-list__filters"> <div className="ticket-list__filters">
{(this.props.type === 'secondary' && this.props.showDepartmentDropdown) ? this.renderDepartments {(this.props.type === 'secondary' && this.props.showDepartmentDropdown) ? this.renderDepartmentsDropDown() : null}
() : null}
{this.props.onClosedTicketsShownChange ? this.renderFilterCheckbox() : null} {this.props.onClosedTicketsShownChange ? this.renderFilterCheckbox() : null}
</div> </div>
<Table {...this.getTableProps()} /> <Table {...this.getTableProps()} />