-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: pagination button * fix: button style
- Loading branch information
Showing
3 changed files
with
176 additions
and
45 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
/** @type {import('ts-jest').JestConfigWithTsJest} */ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
}; | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
moduleNameMapper: { | ||
'^@/(.*)$': '<rootDir>/src/$1', | ||
}, | ||
}; |
113 changes: 113 additions & 0 deletions
113
packages/graphic-walker/src/components/dataTable/pagination.test.ts
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,113 @@ | ||
import { getShowIndices } from './pagination'; | ||
|
||
describe('getShowIndices', () => { | ||
const pageSize = 50; | ||
const extendPageNumber = 1; | ||
test('totalpage 1', () => { | ||
expect(getShowIndices(25, 0, pageSize, extendPageNumber)).toEqual([{ index: 0, disabled: false, type: 'page' }]); | ||
}); | ||
test('totalpage 2', () => { | ||
expect(getShowIndices(100, 0, pageSize, extendPageNumber)).toEqual([ | ||
{ index: 0, disabled: false, type: 'page' }, | ||
{ index: 1, disabled: false, type: 'page' }, | ||
]); | ||
}); | ||
test('totalpage 3', () => { | ||
expect(getShowIndices(150, 0, pageSize, extendPageNumber)).toEqual([ | ||
{ index: 0, disabled: false, type: 'page' }, | ||
{ index: 1, disabled: false, type: 'page' }, | ||
{ index: 2, disabled: false, type: 'page' }, | ||
]); | ||
}); | ||
test('totalpage 4', () => { | ||
expect(getShowIndices(200, 0, pageSize, extendPageNumber)).toEqual([ | ||
{ index: 0, disabled: false, type: 'page' }, | ||
{ index: 1, disabled: false, type: 'page' }, | ||
{ index: -1, type: 'placeholder' }, | ||
{ index: 3, disabled: false, type: 'page' }, | ||
]); | ||
}); | ||
test('totalpage 5', () => { | ||
expect(getShowIndices(250, 0, pageSize, extendPageNumber)).toEqual([ | ||
{ index: 0, disabled: false, type: 'page' }, | ||
{ index: 1, disabled: false, type: 'page' }, | ||
{ index: -1, type: 'placeholder' }, | ||
{ index: 4, disabled: false, type: 'page' }, | ||
]); | ||
}); | ||
test('totalpage 300', () => { | ||
expect(getShowIndices(15000, 0, pageSize, extendPageNumber)).toEqual([ | ||
{ index: 0, disabled: false, type: 'page' }, | ||
{ index: 1, disabled: false, type: 'page' }, | ||
{ index: -1, type: 'placeholder' }, | ||
{ index: 299, disabled: false, type: 'page' }, | ||
]); | ||
}); | ||
test('totalpage 300 pageIndex 150', () => { | ||
expect(getShowIndices(15000, 150, pageSize, extendPageNumber)).toEqual([ | ||
{ index: 0, disabled: false, type: 'page' }, | ||
{ index: -1, type: 'placeholder' }, | ||
{ index: 149, disabled: false, type: 'page' }, | ||
{ index: 150, disabled: false, type: 'page' }, | ||
{ index: 151, disabled: false, type: 'page' }, | ||
{ index: -1, type: 'placeholder' }, | ||
{ index: 299, disabled: false, type: 'page' }, | ||
]); | ||
}); | ||
test('totalpage 2 pageIndex 1', () => { | ||
expect(getShowIndices(100, 1, pageSize, extendPageNumber)).toEqual([ | ||
{ index: 0, disabled: false, type: 'page' }, | ||
{ index: 1, disabled: false, type: 'page' }, | ||
]); | ||
}); | ||
test('totalpage 3 pageIndex 1', () => { | ||
expect(getShowIndices(150, 1, pageSize, extendPageNumber)).toEqual([ | ||
{ index: 0, disabled: false, type: 'page' }, | ||
{ index: 1, disabled: false, type: 'page' }, | ||
{ index: 2, disabled: false, type: 'page' }, | ||
]); | ||
}); | ||
test('totalpage 4 pageIndex 1', () => { | ||
expect(getShowIndices(200, 1, pageSize, extendPageNumber)).toEqual([ | ||
{ index: 0, disabled: false, type: 'page' }, | ||
{ index: 1, disabled: false, type: 'page' }, | ||
{ index: 2, disabled: false, type: 'page' }, | ||
{ index: 3, disabled: false, type: 'page' }, | ||
]); | ||
}); | ||
test('totalpage 5 pageIndex 1', () => { | ||
expect(getShowIndices(250, 1, pageSize, extendPageNumber)).toEqual([ | ||
{ index: 0, disabled: false, type: 'page' }, | ||
{ index: 1, disabled: false, type: 'page' }, | ||
{ index: 2, disabled: false, type: 'page' }, | ||
{ index: -1, type: 'placeholder' }, | ||
{ index: 4, disabled: false, type: 'page' }, | ||
]); | ||
}); | ||
test('totalpage 5 pageIndex 2', () => { | ||
expect(getShowIndices(250, 2, pageSize, extendPageNumber)).toEqual([ | ||
{ index: 0, disabled: false, type: 'page' }, | ||
{ index: 1, disabled: false, type: 'page' }, | ||
{ index: 2, disabled: false, type: 'page' }, | ||
{ index: 3, disabled: false, type: 'page' }, | ||
{ index: 4, disabled: false, type: 'page' }, | ||
]); | ||
}); | ||
test('totalpage 5 pageIndex 3', () => { | ||
expect(getShowIndices(250, 3, pageSize, extendPageNumber)).toEqual([ | ||
{ index: 0, disabled: false, type: 'page' }, | ||
{ index: -1, type: 'placeholder' }, | ||
{ index: 2, disabled: false, type: 'page' }, | ||
{ index: 3, disabled: false, type: 'page' }, | ||
{ index: 4, disabled: false, type: 'page' }, | ||
]); | ||
}); | ||
test('totalpage 5 pageIndex 4', () => { | ||
expect(getShowIndices(250, 4, pageSize, extendPageNumber)).toEqual([ | ||
{ index: 0, disabled: false, type: 'page' }, | ||
{ index: -1, type: 'placeholder' }, | ||
{ index: 3, disabled: false, type: 'page' }, | ||
{ index: 4, disabled: false, type: 'page' }, | ||
]); | ||
}); | ||
}); |
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