-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: 新增测试 * chore: 更新版本 * feat(test): 解决window is not defined bug * refactor(test): 将单测移动到core目录下 * refactor(test): 卸载不必要的依赖
- Loading branch information
1 parent
95129be
commit 528344f
Showing
7 changed files
with
80 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { beforeEach, expect, test } from 'vitest'; | ||
import { createEditor } from '../utils/setup.ts'; | ||
|
||
const { cleanUp } = createEditor(); | ||
|
||
beforeEach(() => { | ||
return cleanUp; | ||
}); | ||
|
||
test('basic', () => { | ||
expect(window.editor).toBeDefined(); | ||
}); |
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,7 @@ | ||
import Editor from '../Editor'; | ||
|
||
declare global { | ||
interface Window { | ||
editor: Editor; | ||
} | ||
} |
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,21 @@ | ||
import Editor from '../../Editor.ts'; | ||
import { fabric } from 'fabric'; | ||
|
||
export function createEditor() { | ||
const editor = new Editor(); | ||
const canvasElement = document.createElement('canvas'); | ||
canvasElement.id = 'canvas'; | ||
const canvas = new fabric.Canvas('canvas', { | ||
fireRightClick: true, | ||
stopContextMenu: true, | ||
controlsAboveOverlay: true, | ||
imageSmoothingEnabled: false, | ||
preserveObjectStacking: true, | ||
}); | ||
editor.init(canvas); | ||
window.editor = editor; | ||
|
||
return { | ||
cleanUp: editor.destory(), | ||
}; | ||
} |
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,21 @@ | ||
import { defineConfig } from 'vitest/config'; | ||
|
||
export default defineConfig((_configEnv) => | ||
defineConfig({ | ||
esbuild: { target: 'es2022' }, | ||
optimizeDeps: { | ||
force: true, | ||
esbuildOptions: { | ||
target: 'es2022', | ||
}, | ||
}, | ||
test: { | ||
include: ['./__tests__/**/*.spec.ts'], | ||
|
||
deps: { | ||
interopDefault: true, | ||
}, | ||
environment: 'jsdom', | ||
}, | ||
}) | ||
); |
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