-
Notifications
You must be signed in to change notification settings - Fork 447
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add unit tests using vitest (#377)
- Loading branch information
1 parent
5ba8f64
commit 8b6c2cd
Showing
6 changed files
with
80 additions
and
0 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,20 @@ | ||
import { it, describe, expect } from 'vitest' | ||
import getCommand from '../utils/getCommand' | ||
|
||
describe('getCommand', () => { | ||
it('should generate the correct command for yarn', () => { | ||
expect(getCommand('yarn', 'install')).toBe('yarn') | ||
expect(getCommand('yarn', 'dev')).toBe('yarn dev') | ||
expect(getCommand('yarn', 'build')).toBe('yarn build') | ||
}) | ||
it('should generate the correct command for npm', () => { | ||
expect(getCommand('npm', 'install')).toBe('npm install') | ||
expect(getCommand('npm', 'dev')).toBe('npm run dev') | ||
expect(getCommand('npm', 'build')).toBe('npm run build') | ||
}) | ||
it('should generate the correct command for pnpm', () => { | ||
expect(getCommand('pnpm', 'install')).toBe('pnpm install') | ||
expect(getCommand('pnpm', 'dev')).toBe('pnpm dev') | ||
expect(getCommand('pnpm', 'build')).toBe('pnpm build') | ||
}) | ||
}) |
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,47 @@ | ||
import { it, describe, expect } from 'vitest' | ||
import sortDependencies from '../utils/sortDependencies' | ||
|
||
describe('sortDependencies', () => { | ||
it('should sort dependencies and dev dependencies', () => { | ||
const packageJson = { | ||
dependencies: { | ||
vue: '^3.3.4', | ||
'vue-router': '^4.2.5', | ||
pinia: '^2.1.7' | ||
}, | ||
devDependencies: { | ||
'@vitejs/plugin-vue-jsx': '^3.0.2', | ||
jsdom: '^22.1.0', | ||
'start-server-and-test': '^2.0.1', | ||
vite: '^4.4.11', | ||
'@vue/test-utils': '^2.4.1', | ||
cypress: '^13.3.1', | ||
eslint: '^8.49.0', | ||
'@vitejs/plugin-vue': '^4.4.0', | ||
'eslint-plugin-cypress': '^2.15.1', | ||
'eslint-plugin-vue': '^9.17.0', | ||
vitest: '^0.34.6' | ||
} | ||
} | ||
expect(sortDependencies(packageJson)).toStrictEqual({ | ||
dependencies: { | ||
pinia: '^2.1.7', | ||
vue: '^3.3.4', | ||
'vue-router': '^4.2.5' | ||
}, | ||
devDependencies: { | ||
'@vitejs/plugin-vue': '^4.4.0', | ||
'@vitejs/plugin-vue-jsx': '^3.0.2', | ||
'@vue/test-utils': '^2.4.1', | ||
cypress: '^13.3.1', | ||
eslint: '^8.49.0', | ||
'eslint-plugin-cypress': '^2.15.1', | ||
'eslint-plugin-vue': '^9.17.0', | ||
jsdom: '^22.1.0', | ||
'start-server-and-test': '^2.0.1', | ||
vite: '^4.4.11', | ||
vitest: '^0.34.6' | ||
} | ||
}) | ||
}) | ||
}) |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 { defineConfig } from 'vitest/config' | ||
|
||
export default defineConfig({ | ||
test: { | ||
include: ['__test__/**.spec.ts'] | ||
} | ||
}) |