|
765 | 765 | }); |
766 | 766 |
|
767 | 767 | describe('specifying columns using a <Thead>', function () { |
768 | | - before(function () { |
769 | | - ReactDOM.render(React.createElement( |
770 | | - Reactable.Table, |
771 | | - { id: 'table', data: [{ Name: Reactable.unsafe('<span id="griffins-name">Griffin Smith</span>'), Age: '18' }, { Age: '28', Position: Reactable.unsafe('<span id="who-knows-job">Developer</span>') }, { Age: '23', Name: Reactable.unsafe('<span id="lees-name">Lee Salminen</span>') }] }, |
772 | | - React.createElement( |
773 | | - Reactable.Thead, |
774 | | - null, |
| 768 | + describe('and an element for the column title', function () { |
| 769 | + before(function () { |
| 770 | + ReactDOM.render(React.createElement( |
| 771 | + Reactable.Table, |
| 772 | + { id: 'table', data: [{ Name: Reactable.unsafe('<span id="griffins-name">Griffin Smith</span>'), Age: '18' }, { Age: '28', Position: Reactable.unsafe('<span id="who-knows-job">Developer</span>') }, { Age: '23', Name: Reactable.unsafe('<span id="lees-name">Lee Salminen</span>') }] }, |
775 | 773 | React.createElement( |
776 | | - Reactable.Th, |
777 | | - { column: 'Name', id: 'my-name' }, |
| 774 | + Reactable.Thead, |
| 775 | + null, |
778 | 776 | React.createElement( |
779 | | - 'strong', |
780 | | - null, |
781 | | - 'name' |
| 777 | + Reactable.Th, |
| 778 | + { column: 'Name', id: 'my-name' }, |
| 779 | + React.createElement( |
| 780 | + 'strong', |
| 781 | + null, |
| 782 | + 'name' |
| 783 | + ) |
782 | 784 | ) |
783 | 785 | ) |
784 | | - ) |
785 | | - ), ReactableTestUtils.testNode()); |
786 | | - }); |
| 786 | + ), ReactableTestUtils.testNode()); |
| 787 | + }); |
787 | 788 |
|
788 | | - after(ReactableTestUtils.resetTestEnvironment); |
| 789 | + after(ReactableTestUtils.resetTestEnvironment); |
789 | 790 |
|
790 | | - it('renders only the columns in the Thead', function () { |
791 | | - expect($('#table tbody tr:first td')).to.exist; |
792 | | - expect($('#table thead tr:first th')).to.exist; |
793 | | - }); |
| 791 | + it('renders only the columns in the Thead', function () { |
| 792 | + expect($('#table tbody tr:first td')).to.exist; |
| 793 | + expect($('#table thead tr:first th')).to.exist; |
| 794 | + }); |
| 795 | + |
| 796 | + it('renders the contents of the Th', function () { |
| 797 | + expect($('#table>thead>tr>th>strong')).to.exist; |
| 798 | + }); |
794 | 799 |
|
795 | | - it('renders the contents of the Th', function () { |
796 | | - expect($('#table>thead>tr>th>strong')).to.exist; |
| 800 | + it('passes through the properties of the Th', function () { |
| 801 | + expect($('#table>thead>tr>th')).to.have.id('my-name'); |
| 802 | + }); |
797 | 803 | }); |
798 | 804 |
|
799 | | - it('passes through the properties of the Th', function () { |
800 | | - expect($('#table>thead>tr>th')).to.have.id('my-name'); |
| 805 | + describe('and a string for the column title', function () { |
| 806 | + before(function () { |
| 807 | + ReactDOM.render(React.createElement( |
| 808 | + Reactable.Table, |
| 809 | + { id: 'table', data: [{ Name: Reactable.unsafe('<span id="griffins-name">Griffin Smith</span>'), Age: '18' }, { Age: '28', Position: Reactable.unsafe('<span id="who-knows-job">Developer</span>') }, { Age: '23', Name: Reactable.unsafe('<span id="lees-name">Lee Salminen</span>') }] }, |
| 810 | + React.createElement( |
| 811 | + Reactable.Thead, |
| 812 | + null, |
| 813 | + React.createElement( |
| 814 | + Reactable.Th, |
| 815 | + { column: 'Name', id: 'my-name' }, |
| 816 | + 'name' |
| 817 | + ) |
| 818 | + ) |
| 819 | + ), ReactableTestUtils.testNode()); |
| 820 | + }); |
| 821 | + |
| 822 | + after(ReactableTestUtils.resetTestEnvironment); |
| 823 | + |
| 824 | + it('renders only the columns in the Thead', function () { |
| 825 | + expect($('#table tbody tr:first td')).to.exist; |
| 826 | + expect($('#table thead tr:first th')).to.exist; |
| 827 | + }); |
| 828 | + |
| 829 | + it('renders the contents of the Th', function () { |
| 830 | + expect($('#table>thead>tr>th')).to.exist; |
| 831 | + }); |
| 832 | + |
| 833 | + it('passes through the properties of the Th', function () { |
| 834 | + expect($('#table>thead>tr>th')).to.have.id('my-name'); |
| 835 | + }); |
801 | 836 | }); |
802 | 837 | }); |
803 | 838 |
|
|
1080 | 1115 | expect($('#table tbody.reactable-data tr').length).to.equal(9); |
1081 | 1116 | }); |
1082 | 1117 | }); |
| 1118 | + |
| 1119 | + describe('onPageChange hook', function () { |
| 1120 | + var currentPage = undefined; |
| 1121 | + var callback = function callback(page) { |
| 1122 | + currentPage = page; |
| 1123 | + }; |
| 1124 | + before(function () { |
| 1125 | + ReactDOM.render(React.createElement(Reactable.Table, { className: 'table', id: 'table', data: [{ 'Name': 'Griffin Smith', 'Age': '18' }, { 'Age': '23', 'Name': 'Lee Salminen' }, { 'Age': '28', 'Position': 'Developer' }, { 'Name': 'Griffin Smith', 'Age': '18' }, { 'Age': '23', 'Name': 'Test Person' }, { 'Name': 'Ian Zhang', 'Age': '28', 'Position': 'Developer' }, { 'Name': 'Griffin Smith', 'Age': '18', 'Position': 'Software Developer' }, { 'Age': '23', 'Name': 'Lee Salminen' }, { 'Age': '28', 'Position': 'Developer' }], itemsPerPage: 4, onPageChange: callback }), ReactableTestUtils.testNode()); |
| 1126 | + }); |
| 1127 | + |
| 1128 | + after(ReactableTestUtils.resetTestEnvironment); |
| 1129 | + |
| 1130 | + it('emits the number of the currently selected page (zero based) when onPageChange event is triggered', function () { |
| 1131 | + var page1 = $('#table tbody.reactable-pagination a.reactable-page-button')[0]; |
| 1132 | + var page2 = $('#table tbody.reactable-pagination a.reactable-page-button')[1]; |
| 1133 | + var page3 = $('#table tbody.reactable-pagination a.reactable-page-button')[2]; |
| 1134 | + ReactTestUtils.Simulate.click(page2); |
| 1135 | + expect(currentPage).to.equal(1); |
| 1136 | + ReactTestUtils.Simulate.click(page1); |
| 1137 | + expect(currentPage).to.equal(0); |
| 1138 | + ReactTestUtils.Simulate.click(page3); |
| 1139 | + expect(currentPage).to.equal(2); |
| 1140 | + }); |
| 1141 | + }); |
1083 | 1142 | }); |
1084 | 1143 |
|
1085 | 1144 | describe('sorting', function () { |
|
0 commit comments