Skip to content

Commit 312dbcf

Browse files
authored
test(utils): [grid,select] add vitest for utils package (#2813)
* test(utils): add vitest for utils package * fix(log): fix * fix(xss): fix * fix(grid): add dependence * fix(grid): fix e2e test * fix(test): fix
1 parent 9ed39c7 commit 312dbcf

File tree

21 files changed

+70
-788
lines changed

21 files changed

+70
-788
lines changed

examples/sites/demos/pc/app/grid/editor/custom-edit.spec.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,5 @@ import { test, expect } from '@playwright/test'
33
test('多行编辑', async ({ page }) => {
44
page.on('pageerror', (exception) => expect(exception).toBeNull())
55
await page.goto('grid-editor#editor-custom-edit')
6-
await expect(page.getByRole('row', { name: '1 请选择 保存 取消' }).getByRole('textbox').first()).toBeVisible()
7-
await expect(page.getByRole('row', { name: '2 请选择 保存 取消' }).getByRole('textbox').first()).toBeVisible()
6+
await expect(page.getByRole('textbox', { name: 'GFD 科技有限公司', exact: true })).toBeVisible()
87
})

packages/mobile/components/file-upload/src/renderless/index.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import type {
3030
} from '../file-upload'
3131

3232
import { extend } from '@mobile-root/utils/object'
33-
import { xss, log } from '@mobile-root/utils/xss'
33+
import { xss, log } from '@mobile-root/utils'
3434
import uploadAjax from '@mobile-root/utils/deps/upload-ajax'
3535
import { isObject } from '@mobile-root/utils/type'
3636
import { isEmptyObject } from '@mobile-root/utils/type'
@@ -577,7 +577,7 @@ export const handleStart =
577577
state,
578578
vm
579579
}: Pick<IFileUploadRenderlessParams, 'api' | 'constants' | 'props' | 'state' | 'vm'>) =>
580-
(rawFiles: IFileUploadFile[], updateId: string, reUpload: boolean = false) => {
580+
(rawFiles: IFileUploadFile[], updateId: string, reUpload = false) => {
581581
if (state.isHwh5) {
582582
rawFiles = handleHwh5Files(rawFiles, props.hwh5)
583583
}
@@ -921,7 +921,7 @@ export const abort =
921921

922922
export const abortDownload =
923923
({ state }: Pick<IFileUploadRenderlessParams, 'state'>) =>
924-
(file: IFileUploadFile, batch: boolean = false) => {
924+
(file: IFileUploadFile, batch = false) => {
925925
const cancel = (docId) => {
926926
if (!docId) return
927927
const cancels = state.downloadCancelToken[docId]
@@ -2246,7 +2246,7 @@ export const getToken =
22462246

22472247
export const previewFile =
22482248
({ api, props }: Pick<IFileUploadRenderlessParams, 'api' | 'props'>) =>
2249-
(file: IFileUploadFile, open: boolean = false) => {
2249+
(file: IFileUploadFile, open = false) => {
22502250
return new Promise((resolve, reject) => {
22512251
try {
22522252
const tokenParams = { isOnlinePreview: true, file, type: 'preview', token: props.edm.preview.token }

packages/renderless/src/common/index.ts

+1-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*/
1212

13-
import { log as uLog, xss } from '@opentiny/utils'
13+
import { xss } from '@opentiny/utils'
1414

1515
export const KEY_CODE = {
1616
Backspace: 8,
@@ -264,8 +264,4 @@ export const CASCADER = {
264264

265265
export const version = process.env.RUNTIME_VERSION
266266

267-
export const log = (data, type = 'log') => {
268-
uLog.logger[type](data)
269-
}
270-
271267
export { xss }

packages/renderless/src/tree/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { on, off } from '../common/deps/dom'
1818
import { getDataset } from '../common/dataset'
1919
import { copyArray } from '../common/object'
2020

21-
import { log } from '../common'
21+
import { log } from '@opentiny/utils'
2222

2323
export const setChildren = (props) => (data) => (props.data = data)
2424

packages/utils/README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
# @opentiny/utils
1+
## 安装
2+
3+
```bash
4+
npm install --save @opentiny/utils
5+
```

packages/utils/package.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"name": "@opentiny/utils",
3+
"type": "module",
34
"version": "1.0.0",
45
"description": "nanoid console xss",
56
"author": "",
67
"license": "ISC",
7-
"type": "module",
88
"repository": {
99
"type": "git",
1010
"url": "git@github.com:opentiny/tiny-vue.git"
@@ -16,14 +16,16 @@
1616
],
1717
"scripts": {
1818
"build": "vite build",
19-
"pub": "pnpm publish --no-git-checks --access=public"
19+
"pub": "pnpm publish --no-git-checks --access=public",
20+
"test": "vitest"
2021
},
2122
"dependencies": {
2223
"xss": "1.0.14"
2324
},
2425
"devDependencies": {
2526
"typescript": "catalog:",
27+
"vite": "catalog:",
2628
"vite-plugin-dts": "~4.3.0",
27-
"vite": "catalog:"
29+
"vitest": "catalog:"
2830
}
2931
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2+
3+
exports[`测试sha256 1`] = `"b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9"`;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { test, expect } from 'vitest'
2+
import { sha256 } from '../index'
3+
4+
test('测试sha256', async () => {
5+
// 简单记录加密的结果,测试用来保证sha256算法不变化
6+
expect(await sha256('hello world')).toMatchSnapshot()
7+
})

0 commit comments

Comments
 (0)