-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add styles as a package export for easier referencing - closes #9 * update dragon-drop-vue and replace window resize debounce with native-event-vue * update dev dependencies * Fix bug in where paging through a sorted grid could cause data to not stay sorted. * setup vitest * v3.2.0
- Loading branch information
Showing
48 changed files
with
2,539 additions
and
775 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
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
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
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
Binary file not shown.
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,6 +1,10 @@ | ||
import { createApp } from 'vue' | ||
import App from './App.vue' | ||
import router from './router' | ||
import { DataGridVue } from '../../lib/main' | ||
import { DataGridVue } from 'data-grid-vue' | ||
import 'data-grid-vue/style' | ||
|
||
createApp(App).use(router).use(DataGridVue).mount('#app') | ||
createApp(App) | ||
.use(router) | ||
.use(DataGridVue, { dragonDropVueOptions: { debugLog: true } }) | ||
.mount('#app') |
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,76 @@ | ||
import { expect, test, describe } from 'vitest' | ||
import { ClientSideDataService, StubDataService } from './DataService' | ||
import { SortType } from './Sort' | ||
import { DataType } from './DataGridVue' | ||
|
||
interface TestDataItem { | ||
id: number | ||
name: string | ||
} | ||
|
||
const TestDataItemOne = { id: 1, name: 'Test 1' } | ||
const TestDataItemTwo = { id: 2, name: 'Test 2' } | ||
const TestDataItemThree = { id: 3, name: 'Test 3' } | ||
const TestDataItemFour = { id: 4, name: 'Test 4' } | ||
const TestDataItemFive = { id: 5, name: 'Test 5' } | ||
|
||
const TestDataSet = [TestDataItemThree, TestDataItemTwo, TestDataItemFour, TestDataItemFive, TestDataItemOne] as TestDataItem[] | ||
|
||
describe('StubDataService', () => { | ||
test('getPageAsync', async () => { | ||
const pageData = await StubDataService.getPageAsync(1, 10, [], undefined) | ||
expect(pageData).toEqual({ | ||
totalItems: 0, | ||
dataItems: [], | ||
}) | ||
}) | ||
}) | ||
|
||
describe('ClientSideDataService', () => { | ||
test('getPageAsync | pages', async () => { | ||
const dataService = new ClientSideDataService([...TestDataSet]) | ||
const pageDataOne = await dataService.getPageAsync(1, 2, [], undefined) | ||
const pageDataTwo = await dataService.getPageAsync(2, 1, [], undefined) | ||
const pageDataThree = await dataService.getPageAsync(2, 3, [], undefined) | ||
expect(pageDataOne).toEqual({ | ||
totalItems: TestDataSet.length, | ||
dataItems: [TestDataItemThree, TestDataItemTwo], | ||
}) | ||
expect(pageDataTwo).toEqual({ | ||
totalItems: TestDataSet.length, | ||
dataItems: [TestDataItemTwo], | ||
}) | ||
expect(pageDataThree).toEqual({ | ||
totalItems: TestDataSet.length, | ||
dataItems: [TestDataItemFive, TestDataItemOne], | ||
}) | ||
}) | ||
|
||
test('getPageAsync | sorts', async () => { | ||
const dataService = new ClientSideDataService([...TestDataSet]) | ||
|
||
const testCases = [ | ||
{ | ||
sort: { fieldName: 'id', dataType: DataType.number, type: SortType.descending }, | ||
pageNum: 1, | ||
pageSize: 2, | ||
expected: [TestDataItemFive, TestDataItemFour], | ||
}, | ||
{ | ||
sort: { fieldName: 'id', dataType: DataType.number, type: SortType.descending }, | ||
pageNum: 2, | ||
pageSize: 2, | ||
expected: [TestDataItemThree, TestDataItemTwo], | ||
}, | ||
{ sort: { fieldName: 'id', dataType: DataType.number, type: SortType.descending }, pageNum: 3, pageSize: 2, expected: [TestDataItemOne] }, | ||
] | ||
|
||
for (const testCase of testCases) { | ||
const pageData = await dataService.getPageAsync(testCase.pageNum, testCase.pageSize, [testCase.sort], undefined) | ||
expect(pageData).toEqual({ | ||
totalItems: TestDataSet.length, | ||
dataItems: testCase.expected, | ||
}) | ||
} | ||
}) | ||
}) |
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
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
Oops, something went wrong.