-
Notifications
You must be signed in to change notification settings - Fork 0
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 #4 from dream-num/test/add-test
test: add test cases
- Loading branch information
Showing
8 changed files
with
1,986 additions
and
33 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,3 +25,6 @@ Thumbs.db | |
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
# Test | ||
coverage |
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,42 @@ | ||
import fs from 'fs-extra' | ||
import { createProject } from '../src/create' | ||
import { traverseDirectory } from '../src/utils/convert' | ||
|
||
jest.mock('fs-extra') | ||
jest.mock('../src/utils/convert') | ||
|
||
describe('createProject', () => { | ||
beforeEach(() => { | ||
jest.clearAllMocks() | ||
}) | ||
|
||
it('should copy files from source directory to destination directory', () => { | ||
// Arrange | ||
const fromDir = '/path/to/source' | ||
const toDir = '/path/to/destination' | ||
const projectName = 'myProject' | ||
|
||
// Act | ||
createProject(fromDir, toDir, projectName) | ||
|
||
// Assert | ||
expect(fs.copySync).toHaveBeenCalledWith(fromDir, toDir, { overwrite: true }) | ||
}) | ||
|
||
it('should call traverseDirectory with the correct arguments', () => { | ||
// Arrange | ||
const fromDir = '/path/to/source' | ||
const toDir = '/path/to/destination' | ||
const projectName = 'myProject' | ||
|
||
// Act | ||
createProject(fromDir, toDir, projectName) | ||
|
||
// Assert | ||
expect(traverseDirectory).toHaveBeenCalledWith(toDir, { | ||
GITIGNORE: '.gitignore', | ||
PROJECT_NAME: projectName, | ||
PROJECT_UPPER_NAME: 'MyProject' | ||
}) | ||
}) | ||
}) |
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,9 @@ | ||
import type { JestConfigWithTsJest } from 'ts-jest' | ||
|
||
export default { | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
testPathIgnorePatterns: ['/node_modules/', '/templates/'], | ||
collectCoverageFrom: ['<rootDir>/src/**/*.ts'], | ||
coveragePathIgnorePatterns: ['/node_modules/', '/templates/'], | ||
} as JestConfigWithTsJest |
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,9 +1,8 @@ | ||
{ | ||
"name": "@univerjs/create-cli", | ||
"version": "0.3.1", | ||
"description": "", | ||
"description": "Command-line tool for quickly creating univer plugins.", | ||
"main": "index.js", | ||
"type": "module", | ||
"author": "DreamNum <[email protected]>", | ||
"license": "MIT", | ||
"publishConfig": { | ||
|
@@ -15,6 +14,8 @@ | |
"scripts": { | ||
"dev": "node ./esbuild.config.mjs --watch", | ||
"build": "node ./esbuild.config.mjs", | ||
"test": "jest", | ||
"coverage": "jest --coverage", | ||
"release": "npm run build && release-it" | ||
}, | ||
"dependencies": { | ||
|
@@ -27,10 +28,14 @@ | |
"devDependencies": { | ||
"@types/ejs": "^3.1.5", | ||
"@types/fs-extra": "^11.0.4", | ||
"@types/jest": "^29.5.11", | ||
"esbuild": "^0.19.11", | ||
"esbuild-plugin-clean": "^1.0.1", | ||
"jest": "^29.7.0", | ||
"minimist": "^1.2.8", | ||
"release-it": "^17.0.1", | ||
"ts-jest": "^29.1.1", | ||
"ts-node": "^10.9.2", | ||
"typescript": "^5.3.3" | ||
} | ||
} |
Oops, something went wrong.