-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:ravid7000/table-sortable
- Loading branch information
Showing
8 changed files
with
16,206 additions
and
6,991 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
Large diffs are not rendered by default.
Oops, something went wrong.
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,173 @@ | ||
const data = [ | ||
{ | ||
formCode: 531718, | ||
formName: 'Investment Form', | ||
fullName: 'Test User', | ||
appointmentDate: '13 March, 2017', | ||
appointmentTime: '1:30PM', | ||
phone: '9876543210', | ||
}, | ||
{ | ||
formCode: 531790, | ||
formName: 'Investment Form 2', | ||
fullName: 'Test User', | ||
appointmentDate: '12 March, 2017', | ||
appointmentTime: '1:35PM', | ||
phone: '9876543210', | ||
}, | ||
{ | ||
formCode: 531334, | ||
formName: 'Investment Form 3', | ||
fullName: 'Test User', | ||
appointmentDate: '10 March, 2017', | ||
appointmentTime: '1:40PM', | ||
phone: '9876543210', | ||
}, | ||
{ | ||
formCode: 5317, | ||
formName: 'Investment Form 4', | ||
fullName: 'Test User', | ||
appointmentDate: '17 March, 2017', | ||
appointmentTime: '1:20PM', | ||
phone: '9876543210', | ||
}, | ||
{ | ||
formCode: 531334, | ||
formName: 'Investment Form 3', | ||
fullName: 'Test User', | ||
appointmentDate: '10 March, 2017', | ||
appointmentTime: '1:40PM', | ||
phone: '9876543210', | ||
}, | ||
{ | ||
formCode: 5317, | ||
formName: 'Investment Form 4', | ||
fullName: 'Test User', | ||
appointmentDate: '17 March, 2017', | ||
appointmentTime: '1:20PM', | ||
phone: '9876543210', | ||
}, | ||
{ | ||
formCode: 531334, | ||
formName: 'Investment Form 3', | ||
fullName: 'Test User', | ||
appointmentDate: '10 March, 2017', | ||
appointmentTime: '1:40PM', | ||
phone: '9876543210', | ||
}, | ||
{ | ||
formCode: 5317, | ||
formName: 'Investment Form 4', | ||
fullName: 'Test User', | ||
appointmentDate: '17 March, 2017', | ||
appointmentTime: '1:20PM', | ||
phone: '9876543210', | ||
}, | ||
{ | ||
formCode: 531334, | ||
formName: 'Investment Form 3', | ||
fullName: 'Test User', | ||
appointmentDate: '10 March, 2017', | ||
appointmentTime: '1:40PM', | ||
phone: '9876543210', | ||
}, | ||
{ | ||
formCode: 5317, | ||
formName: 'Investment Form 4', | ||
fullName: 'Test User', | ||
appointmentDate: '17 March, 2017', | ||
appointmentTime: '1:20PM', | ||
phone: '9876543210', | ||
}, | ||
{ | ||
formCode: 531334, | ||
formName: 'Investment Form 3', | ||
fullName: 'Test User', | ||
appointmentDate: '10 March, 2017', | ||
appointmentTime: '1:40PM', | ||
phone: '9876543210', | ||
}, | ||
{ | ||
formCode: 5317, | ||
formName: 'Investment Form 4', | ||
fullName: 'Test User', | ||
appointmentDate: '17 March, 2017', | ||
appointmentTime: '1:20PM', | ||
phone: '9876543210', | ||
}, | ||
{ | ||
formCode: 531334, | ||
formName: 'Investment Form 3', | ||
fullName: 'Test User', | ||
appointmentDate: '10 March, 2017', | ||
appointmentTime: '1:40PM', | ||
phone: '9876543210', | ||
}, | ||
{ | ||
formCode: 5317, | ||
formName: 'Investment Form 4', | ||
fullName: 'Test User', | ||
appointmentDate: '17 March, 2017', | ||
appointmentTime: '1:20PM', | ||
phone: '9876543210', | ||
}, | ||
{ | ||
formCode: 531334, | ||
formName: 'Investment Form 3', | ||
fullName: 'Test User', | ||
appointmentDate: '10 March, 2017', | ||
appointmentTime: '1:40PM', | ||
phone: '9876543210', | ||
}, | ||
{ | ||
formCode: 5317, | ||
formName: 'Investment Form 4', | ||
fullName: 'Test User', | ||
appointmentDate: '17 March, 2017', | ||
appointmentTime: '1:20PM', | ||
phone: '9876543210', | ||
}, | ||
{ | ||
formCode: 531334, | ||
formName: 'Investment Form 3', | ||
fullName: 'Test User', | ||
appointmentDate: '10 March, 2017', | ||
appointmentTime: '1:40PM', | ||
phone: '9876543210', | ||
}, | ||
{ | ||
formCode: 5317, | ||
formName: 'Investment Form 4', | ||
fullName: 'Test User', | ||
appointmentDate: '17 March, 2017', | ||
appointmentTime: '1:20PM', | ||
phone: '9876543210', | ||
}, | ||
{ | ||
formCode: 531334, | ||
formName: 'Investment Form 3', | ||
fullName: 'Test User', | ||
appointmentDate: '10 March, 2017', | ||
appointmentTime: '1:40PM', | ||
phone: '9876543210', | ||
}, | ||
{ | ||
formCode: 5317, | ||
formName: 'Investment Form 4', | ||
fullName: 'Test User', | ||
appointmentDate: '17 March, 2017', | ||
appointmentTime: '1:20PM', | ||
phone: '9876543210', | ||
}, | ||
] | ||
|
||
const columns = { | ||
formCode: 'Form Code', | ||
formName: 'Form Name', | ||
fullName: 'Full Name', | ||
appointmentDate: 'Appointment Date', | ||
appointmentTime: 'Appointment Time', | ||
phone: 'Phone', | ||
} | ||
|
||
export { data, columns } |
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,97 @@ | ||
import $ from 'jquery' | ||
import TableSortable from '..' | ||
|
||
const rootElm = '#root' | ||
|
||
beforeAll(() => { | ||
document.body.innerHTML = ` | ||
<div id="root"></div> | ||
` | ||
}) | ||
describe('Table Sortable Options:', () => { | ||
test('should be mounted without breaking', () => { | ||
const table = new TableSortable({ | ||
element: rootElm, | ||
}) | ||
expect(table._isMounted).toStrictEqual(true) | ||
expect($(rootElm).find('table').length).toStrictEqual(1) | ||
}) | ||
test('should create options from default options', () => { | ||
const table = new TableSortable({ | ||
element: rootElm, | ||
}) | ||
expect(table.options).toMatchObject({ | ||
element: rootElm, | ||
data: [], | ||
columns: {}, | ||
sorting: true, | ||
pagination: true, | ||
paginationContainer: null, | ||
rowsPerPage: 10, | ||
formatCell: null, | ||
formatHeader: null, | ||
searchField: null, | ||
responsive: {}, | ||
totalPages: 0, | ||
sortingIcons: { | ||
asc: '<span>▼</span>', | ||
desc: '<span>▲</span>', | ||
}, | ||
nextText: '<span>Next</span>', | ||
prevText: '<span>Prev</span>', | ||
onPaginationChange: null, | ||
}) | ||
}) | ||
test('lifeCycle should call tableWillMount', () => { | ||
const tableWillMount = jest.fn() | ||
const table = new TableSortable({ | ||
element: rootElm, | ||
tableWillMount, | ||
}) | ||
expect(table.options.tableWillMount).toHaveBeenCalledTimes(1) | ||
}) | ||
test('lifeCycle should call tableDidMount', () => { | ||
const tableDidMount = jest.fn() | ||
const table = new TableSortable({ | ||
element: rootElm, | ||
tableDidMount, | ||
}) | ||
expect(table.options.tableDidMount).toHaveBeenCalledTimes(1) | ||
}) | ||
test('lifeCycle should call tableWillUpdate', () => { | ||
const tableWillUpdate = jest.fn() | ||
const table = new TableSortable({ | ||
element: rootElm, | ||
tableWillUpdate, | ||
}) | ||
table.refresh() | ||
expect(table.options.tableWillUpdate).toHaveBeenCalledTimes(1) | ||
}) | ||
test('lifeCycle should call tableDidUpdate', () => { | ||
const tableDidUpdate = jest.fn() | ||
const table = new TableSortable({ | ||
element: rootElm, | ||
tableDidUpdate, | ||
}) | ||
table.refresh() | ||
expect(table.options.tableDidUpdate).toHaveBeenCalledTimes(1) | ||
}) | ||
test('lifeCycle should call tableWillUnmount', () => { | ||
const tableWillUnmount = jest.fn() | ||
const table = new TableSortable({ | ||
element: rootElm, | ||
tableWillUnmount, | ||
}) | ||
table.distroy() | ||
expect(table.options.tableWillUnmount).toHaveBeenCalledTimes(1) | ||
}) | ||
test('lifeCycle should call tableDidUnmount', () => { | ||
const tableDidUnmount = jest.fn() | ||
const table = new TableSortable({ | ||
element: rootElm, | ||
tableDidUnmount, | ||
}) | ||
table.distroy() | ||
expect(table.options.tableDidUnmount).toHaveBeenCalledTimes(1) | ||
}) | ||
}) |
Oops, something went wrong.