test: 优化测试代码 #80
@ -1,4 +1,5 @@
|
||||
import { expect, test, describe } from 'vitest';
|
||||
import { formatFileSize, getFileExtension, formatFileExtension } from './file';
|
||||
|
||||
/**
|
||||
* 单元测试: formatFileSize
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
import { isObject } from '../../server/utils/object';
|
||||
|
||||
/**
|
||||
* 将 Directus 返回的 Document 数据转换为 ProductDocumentView 视图模型
|
||||
*
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import { toProductQuestionView } from './questionMapper';
|
||||
import { toProductDocumentView } from './documentMapper';
|
||||
import { isObject } from '../../server/utils/object';
|
||||
|
||||
/**
|
||||
* 将Directus返回的ProductType数据转换为ProductTypeView视图模型
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
import { isObject } from '../../server/utils/object';
|
||||
|
||||
/**
|
||||
* 将 Directus 返回的 Question 数据转换为 ProductQuestionView 视图模型
|
||||
*
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
import { isObject } from '../../server/utils/object';
|
||||
|
||||
/**
|
||||
* 将 Directus 返回的 SolutionType 数据转换为 SolutionTypeView 视图模型
|
||||
*
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { expect, test, describe } from 'vitest';
|
||||
import { isObject, isArrayOfObject } from './object';
|
||||
|
||||
/**
|
||||
* 单元测试: isObject
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { describe, expect, test } from 'vitest';
|
||||
import { converters } from './search-converters';
|
||||
|
||||
/**
|
||||
* 单元测试: converters
|
||||
@ -69,7 +70,7 @@ describe('converters', () => {
|
||||
expect(result).toEqual({
|
||||
id: 'TEST-UUID',
|
||||
title: 'User Manual',
|
||||
summary: undefined,
|
||||
summary: '',
|
||||
type: 'document',
|
||||
});
|
||||
});
|
||||
@ -1,7 +1,36 @@
|
||||
import { defineVitestConfig } from '@nuxt/test-utils/config';
|
||||
import { defineConfig } from 'vitest/config';
|
||||
import { defineVitestProject } from '@nuxt/test-utils/config';
|
||||
|
||||
export default defineVitestConfig({
|
||||
export default defineConfig({
|
||||
test: {
|
||||
environment: 'nuxt',
|
||||
globals: true,
|
||||
projects: [
|
||||
{
|
||||
test: {
|
||||
name: 'unit',
|
||||
include: [
|
||||
'app/**/*.test.ts',
|
||||
'app/**/*.spec.ts',
|
||||
'server/**/*.test.ts',
|
||||
'server/**/*.spec.ts',
|
||||
],
|
||||
environment: 'node',
|
||||
},
|
||||
},
|
||||
await defineVitestProject({
|
||||
test: {
|
||||
name: 'nuxt',
|
||||
include: ['tests/nuxt/**/*.{test,spec}.ts'],
|
||||
environment: 'nuxt',
|
||||
},
|
||||
}),
|
||||
{
|
||||
test: {
|
||||
name: 'e2e',
|
||||
include: ['test/e2e/*.{test,spec}.ts'],
|
||||
environment: 'node',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user