-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #179 from actiontech/feature_test_order
[test](sqle/order): Residual unit test for order
- Loading branch information
Showing
69 changed files
with
64,640 additions
and
43 deletions.
There are no files selected for viewing
80 changes: 80 additions & 0 deletions
80
packages/sqle/src/page/Order/AuditDetail/DataSourceResultList/WaterfallList.test.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,80 @@ | ||
import { renderWithTheme } from '../../../../testUtils/customRender'; | ||
import { cleanup } from '@testing-library/react'; | ||
|
||
import { DataSourceResultWaterfallListProps } from '../index.type'; | ||
import DataSourceWaterfallList from './WaterfallList'; | ||
|
||
import { mockUseCurrentUser } from '@actiontech/shared/lib/testUtil/mockHook/mockUseCurrentUser'; | ||
import { IAuditTaskSQLResV2 } from '@actiontech/shared/lib/api/sqle/service/common'; | ||
|
||
const mockListData: IAuditTaskSQLResV2[] = []; | ||
for (let i = 0; i < 50; i++) { | ||
mockListData.push({ | ||
number: i + 1, | ||
audit_level: '', | ||
audit_result: [ | ||
{ | ||
level: 'level' | ||
} | ||
], | ||
audit_status: 'audit_status' + i, | ||
description: 'description' + i, | ||
exec_result: 'exec_result' + i, | ||
exec_sql: 'exec_sql' + i, | ||
exec_status: 'exec_status' + i, | ||
rollback_sql: 'rollback_sql' + i | ||
}); | ||
} | ||
|
||
describe('sqle/Order/AuditDetail/DataSourceWaterfallList', () => { | ||
const customRender = (params: DataSourceResultWaterfallListProps) => { | ||
return renderWithTheme(<DataSourceWaterfallList {...params} />); | ||
}; | ||
|
||
beforeEach(() => { | ||
jest.useFakeTimers(); | ||
mockUseCurrentUser(); | ||
}); | ||
|
||
afterEach(() => { | ||
jest.useRealTimers(); | ||
jest.clearAllMocks(); | ||
cleanup(); | ||
}); | ||
|
||
it('render snap when loading', () => { | ||
const { baseElement } = customRender({ | ||
hasMore: false, | ||
loading: true, | ||
taskId: 'task id', | ||
scrollPage: 1, | ||
refreshScrollList: jest.fn(), | ||
list: undefined | ||
}); | ||
expect(baseElement).toMatchSnapshot(); | ||
}); | ||
|
||
it('render all data', async () => { | ||
const { baseElement } = customRender({ | ||
hasMore: false, | ||
loading: false, | ||
taskId: 'task id', | ||
scrollPage: 1, | ||
refreshScrollList: jest.fn(), | ||
list: mockListData | ||
}); | ||
expect(baseElement).toMatchSnapshot(); | ||
}); | ||
|
||
it('render has more data', async () => { | ||
const { baseElement } = customRender({ | ||
hasMore: true, | ||
loading: false, | ||
taskId: 'task id', | ||
scrollPage: 5, | ||
refreshScrollList: jest.fn(), | ||
list: mockListData | ||
}); | ||
expect(baseElement).toMatchSnapshot(); | ||
}); | ||
}); |
Oops, something went wrong.