-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5b37a76
commit bacba77
Showing
66 changed files
with
5,712 additions
and
768 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { DataClient } from '@infinite-table/infinite-react'; | ||
|
||
(globalThis as any).DataClient = DataClient; | ||
export default function () { | ||
return <div>hello world</div>; | ||
} |
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 |
---|---|---|
@@ -1,20 +1,19 @@ | ||
import { test, expect } from '@playwright/test'; | ||
import { test, expect } from '@testing'; | ||
|
||
export default test.describe.parallel('DataSource', () => { | ||
test.beforeEach(async ({ page }) => { | ||
await page.goto(`tests/datasource/default`); | ||
}); | ||
test('should show loading for 2 seconds', async ({ page }) => { | ||
await page.load(); | ||
const container = page.getByLabel('container'); | ||
|
||
test.skip('should show loading for 2 seconds', async ({ page }) => { | ||
await expect(await page.content()).toContain('loading'); | ||
await expect(await container.textContent()).toContain('loading'); | ||
|
||
await page.waitForTimeout(100); | ||
await page.waitForTimeout(20); | ||
|
||
await expect(await page.content()).toContain('loading'); | ||
await expect(await container.textContent()).toContain('loading'); | ||
|
||
await page.waitForTimeout(250); | ||
await page.waitForTimeout(200); | ||
|
||
await expect(await page.content()).toContain('bob'); | ||
await expect(await page.content()).toContain('bill'); | ||
await expect(await container.textContent()).toContain('bob'); | ||
await expect(await container.textContent()).toContain('bill'); | ||
}); | ||
}); |
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,22 @@ | ||
import * as React from 'react'; | ||
|
||
import { useDataSourceInternal } from '@src/index'; | ||
|
||
const sinon = require('sinon'); | ||
|
||
const data = sinon.spy(() => { | ||
return [ | ||
{ name: 'bob', age: 1, id: 1 }, | ||
{ name: 'bill', age: 2, id: 2 }, | ||
]; | ||
}); | ||
|
||
(globalThis as any).dataFn = data; | ||
export default () => { | ||
const { state } = useDataSourceInternal({ | ||
data, | ||
primaryKey: 'id', | ||
}); | ||
(globalThis as any).dataSourceState = state; | ||
return <div>hello</div>; | ||
}; |
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,14 @@ | ||
import { test, expect, Page } from '@testing'; | ||
import { getFnCalls } from '../testUtils/getFnCalls'; | ||
|
||
async function getCalls({ page }: { page: Page }) { | ||
return await getFnCalls('dataFn', { page }); | ||
} | ||
|
||
export default test.describe.parallel('DataSource data fn', () => { | ||
test('should work correctly', async ({ page }) => { | ||
await page.load(); | ||
|
||
expect((await getCalls({ page })).length).toBe(1); | ||
}); | ||
}); |
4 changes: 2 additions & 2 deletions
4
examples/src/pages/tests/datasource/sortinfo-controlled.page.tsx
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
38 changes: 38 additions & 0 deletions
38
examples/src/pages/tests/datasource/useDataSource/default.page.tsx
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,38 @@ | ||
import * as React from 'react'; | ||
|
||
import { useDataSourceInternal } from '@infinite-table/infinite-react'; | ||
|
||
interface Person { | ||
name: string; | ||
age: number; | ||
id: string | number; | ||
} | ||
|
||
const persons: Person[] = [ | ||
{ name: 'bob', age: 1, id: 1 }, | ||
{ name: 'bill', age: 2, id: 2 }, | ||
]; | ||
|
||
const personsPromise: Promise<Person[]> = new Promise((resolve) => { | ||
setTimeout(() => { | ||
resolve(persons); | ||
}, 200); | ||
}); | ||
|
||
const Cmp = () => { | ||
const { | ||
state: { loading, dataArray }, | ||
} = useDataSourceInternal<Person>({ | ||
data: personsPromise, | ||
primaryKey: 'id', | ||
}); | ||
|
||
return ( | ||
<div aria-label="container" style={{ color: 'tomato' }}> | ||
{loading ? 'loading' : null} | ||
{loading ? null : JSON.stringify(dataArray)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default () => <Cmp />; |
19 changes: 19 additions & 0 deletions
19
examples/src/pages/tests/datasource/useDataSource/default.spec.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,19 @@ | ||
import { test, expect } from '@testing'; | ||
|
||
export default test.describe.parallel('useDataSource', () => { | ||
test('should show loading for 2 seconds', async ({ page }) => { | ||
await page.load(); | ||
const container = page.getByLabel('container'); | ||
|
||
await expect(await container.textContent()).toContain('loading'); | ||
|
||
await page.waitForTimeout(20); | ||
|
||
await expect(await container.textContent()).toContain('loading'); | ||
|
||
await page.waitForTimeout(200); | ||
|
||
await expect(await container.textContent()).toContain('bob'); | ||
await expect(await container.textContent()).toContain('bill'); | ||
}); | ||
}); |
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.