Skip to content

Commit f399e95

Browse files
committed
👕 refactor: unit tests
1 parent f6235d4 commit f399e95

File tree

15 files changed

+2794
-1413
lines changed

15 files changed

+2794
-1413
lines changed

.circleci/config.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ jobs:
4141
# run tests!
4242
- run: yarn lint
4343
- run: yarn test
44-
- run: yarn ci:coverage
4544

4645
- codecov/upload:
47-
file: ./coverage.lcov
46+
file: ./coverage/lcov.info

.eslintrc.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
module.exports = {
44
root: true,
55
env: {
6-
node: true
6+
node: true,
7+
jest: true
78
},
89
extends: [
910
'plugin:vue-libs/recommended'

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
coverage
2-
coverage.lcov
32
node_modules
43
.DS_Store
4+
__snapshots__
55
*.log
66
*.swp
77
*~

.nyc_output/.gitkeep

Whitespace-only changes.

jest.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
'use strict'
2+
3+
module.exports = {
4+
coveragePathIgnorePatterns: [
5+
'node_modules',
6+
'<rootDir>/test/*.*'
7+
]
8+
}

package.json

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,28 @@
66
"name": "kazuya kawaguchi",
77
"email": "[email protected]"
88
},
9-
"ava": {
10-
"require": [
11-
"@babel/register"
12-
]
13-
},
149
"bugs": {
1510
"url": "https://github.com/kazupon/vue-i18n-loader/issues"
1611
},
1712
"devDependencies": {
1813
"@babel/cli": "^7.5.0",
1914
"@babel/core": "^7.5.4",
20-
"@babel/register": "^7.4.4",
21-
"ava": "^1.1.0",
2215
"babel-eslint": "^10.0.2",
16+
"babel-jest": "^24.8.0",
2317
"babel-preset-env": "^1.7.0",
2418
"conventional-changelog-cli": "^2.0.12",
2519
"conventional-github-releaser": "^3.1.2",
2620
"cross-env": "^5.2.0",
2721
"eslint": "^6.0.0",
2822
"eslint-plugin-vue-libs": "^4.0.0",
2923
"git-commit-message-convention": "git://github.com/kazupon/git-commit-message-convention.git",
30-
"nyc": "^13.3.0",
31-
"opener": "^1.5.1"
24+
"jest": "^24.8.0",
25+
"jsdom": "^15.1.1",
26+
"memory-fs": "^0.4.1",
27+
"opener": "^1.5.1",
28+
"vue-loader": "^15.7.0",
29+
"vue-template-compiler": "^2.6.10",
30+
"webpack": "^4.35.3"
3231
},
3332
"engines": {
3433
"node": ">= 8"
@@ -53,14 +52,13 @@
5352
"scripts": {
5453
"build": "cross-env BABEL_ENV=production babel ./src --out-dir ./lib",
5554
"changelog": "conventional-changelog -i CHANGELOG.md -s -n ./node_modules/git-commit-message-convention/convention.js",
56-
"ci:coverage": "nyc report --reporter=text-lcov > coverage.lcov",
5755
"clean": "rm -rf ./coverage && rm -rf ./lib/*.js*",
58-
"coverage": "nyc report --reporter lcov && opener coverage/lcov-report/index.html",
56+
"coverage": "opener coverage/lcov-report/index.html",
5957
"lint": "eslint ./src ./test",
6058
"release": "conventional-github-releaser -n ./node_modules/git-commit-message-convention/convention.js",
6159
"test": "npm run lint && npm run test:cover",
62-
"test:cover": "cross-env BABEL_ENV=test nyc ava",
63-
"test:unit": "cross-env BABEL_ENV=test ava",
60+
"test:cover": "npm run test:unit -- --coverage",
61+
"test:unit": "cross-env BABEL_ENV=test jest --env node",
6462
"watch": "cross-env BABEL_ENV=development babel ./src --out-dir ./lib --watch"
6563
}
6664
}

test/fixtures/basic.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<i18n>
2+
{
3+
"en": {
4+
"hello": "hello world!"
5+
}
6+
}
7+
</i18n>

test/fixtures/entry.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import Component from '~target'
2+
import * as exports from '~target'
3+
4+
if (typeof window !== 'undefined') {
5+
window.module = Component
6+
window.exports = exports
7+
}
8+
9+
export default Component

test/fixtures/import.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<i18n src="./message.json">
2+
</i18n>

test/fixtures/message.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"en": {
3+
"hello": "hello world!"
4+
}
5+
}

0 commit comments

Comments
 (0)