Skip to content

Commit

Permalink
chore: tests setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Novout committed Sep 27, 2021
1 parent 765e949 commit 5094475
Show file tree
Hide file tree
Showing 9 changed files with 2,079 additions and 35 deletions.
File renamed without changes.
25 changes: 25 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Tests

on:
push:
branches: [ main, master, develop ]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [12.x, 14.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: yarn
- name: Run tests
run: yarn test
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ dist-ssr
.vscode
components.d.ts
TODO.md
yarn-error.log
yarn-error.log
coverage
11 changes: 11 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: '',
testEnvironment: 'jsdom',
setupFilesAfterEnv: ['./jest.setup.ts'],
collectCoverage: true,
collectCoverageFrom: [
'**/use/*.ts',
'!**/node_modules/**',
],
};
Empty file added jest.setup.ts
Empty file.
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"build": "vue-tsc --noEmit && vite build",
"serve": "rm -rf ./dist && yarn build && vite preview",
"lint": "eslint --ext .js,.vue --ignore-path .gitignore --fix src && yarn format",
"format": "prettier src/**/*.{vue,css,ts} --write"
"format": "prettier src/**/*.{vue,css,ts} --write",
"test": "jest"
},
"dependencies": {
"@headlessui/vue": "^1.4.1",
Expand All @@ -30,6 +31,7 @@
},
"devDependencies": {
"@intlify/vite-plugin-vue-i18n": "^2.4.0",
"@types/jest": "^27.0.2",
"@types/pdfmake": "^0.1.18",
"@typescript-eslint/eslint-plugin": "^4.31.1",
"@typescript-eslint/parser": "^4.31.1",
Expand All @@ -39,7 +41,9 @@
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-vue": "^7.18.0",
"jest": "^27.2.2",
"prettier": "^2.4.1",
"ts-jest": "^27.0.5",
"typescript": "^4.4.3",
"unplugin-vue-components": "^0.15.2",
"vite": "^2.5.4",
Expand Down
24 changes: 24 additions & 0 deletions test/raw.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* @jest-environment jsdom
*/

import { useFormat } from '../src/use/format';
import { useRaw } from '../src/use/raw';

describe('Factory.Sprite', () => {
beforeEach(() => {});

it('should not convert unnecessary paragraph', () => {
const entity = {
id: 0,
type: 'heading-one',
raw: 'Untitled',
createdAt: useFormat().actually(),
updatedAt: useFormat().actually(),
};

const raw = useRaw().convert(entity);

expect(entity.raw).toEqual(raw);
})
})
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
"sourceMap": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"types": ["@intlify/vite-plugin-vue-i18n/client", "vite/client"],
"types": ["@intlify/vite-plugin-vue-i18n/client", "vite/client", "jest"],
"paths": {
"@/*": ["src/*"]
},
"lib": ["esnext", "dom", "dom.iterable", "scripthost"]
},
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
"exclude": ["node_modules", "/pdfmake.js$/"]
"exclude": ["node_modules", "/pdfmake.js$/", "**/*.test.ts"]
}

0 comments on commit 5094475

Please sign in to comment.