diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 036e747..b4670f0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,4 +12,4 @@ jobs: run: | npm install npm run lint - npm run test:unit + npm run test:coverage diff --git a/.gitignore b/.gitignore index a0dddc6..01fd251 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,5 @@ yarn-error.log* *.njsproj *.sln *.sw? + +coverage diff --git a/dev/App.vue b/dev/App.vue index 09f30fb..e163fd7 100644 --- a/dev/App.vue +++ b/dev/App.vue @@ -70,31 +70,38 @@ }, methods: { onDel (node) { + // eslint-disable-next-line no-console console.log(node) node.remove() }, onChangeName (params) { + // eslint-disable-next-line no-console console.log(params) }, onAddNode (params) { + // eslint-disable-next-line no-console console.log(params) }, onClick (params) { + // eslint-disable-next-line no-console console.log(params) }, drop: function ({node, src, target}) { + // eslint-disable-next-line no-console console.log('drop', node, src, target) }, dropBefore: function ({node, src, target}) { + // eslint-disable-next-line no-console console.log('drop-before', node, src, target) }, dropAfter: function ({node, src, target}) { + // eslint-disable-next-line no-console console.log('drop-after', node, src, target) }, diff --git a/jest.config.js b/jest.config.js index e66cb0e..87cc90c 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,4 +1,6 @@ module.exports = { - preset: "@vue/cli-plugin-unit-jest", - snapshotSerializers: ["jest-serializer-vue"] -}; + preset: '@vue/cli-plugin-unit-jest', + snapshotSerializers: ['jest-serializer-vue'], + collectCoverageFrom: ['src/**/*.{js,vue}'], + coveragePathIgnorePatterns: ['src/index.js'] +} diff --git a/package.json b/package.json index 1c53d5e..cd72cfc 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,8 @@ "scripts": { "serve": "vue-cli-service serve dev", "build": "vue-cli-service build --target lib src/index.js", - "test:unit": "vue-cli-service test:unit", + "test:unit": "vue-cli-service test:unit --watch", + "test:coverage": "vue-cli-service test:unit --coverage", "lint": "vue-cli-service lint", "commit": "npx git-cz", "prepublish": "npm run build" diff --git a/readme.md b/readme.md index 8b19761..382c761 100644 --- a/readme.md +++ b/readme.md @@ -1,3 +1,5 @@ +[![Actions Status](https://github.com/ParadeTo/vue-tree-list/workflows/Test/badge.svg)](https://github.com/ParadeTo/vue-tree-list/actions) + # vue-tree-list A vue component for tree structure. Support adding treenode/leafnode, editing node's name and dragging. diff --git a/src/Tree.js b/src/Tree.js index 083f946..facc879 100644 --- a/src/Tree.js +++ b/src/Tree.js @@ -115,7 +115,7 @@ TreeNode.prototype._beforeInsert = function (target) { return false } - // cannot move ancestor to child + // cannot insert ancestor to child if (this.isTargetChild(target)) { return false } diff --git a/src/VueTreeList.vue b/src/VueTreeList.vue index d670733..61885f9 100644 --- a/src/VueTreeList.vue +++ b/src/VueTreeList.vue @@ -1,12 +1,17 @@