Skip to content

Commit bd49a45

Browse files
Merge pull request #520 from lionel-bijaoui/lb_code_coverage_reactivation
Code coverage reactivation
2 parents f7195e9 + 46fd658 commit bd49a45

File tree

7 files changed

+64
-23
lines changed

7 files changed

+64
-23
lines changed

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
dist/*.js
22
!.eslintrc.js
3+
tests/unit/coverage

.travis.yml

+1-5
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,12 @@ cache:
66
node_js:
77
- "10"
88
- "8"
9-
- "6"
10-
11-
before_install:
12-
- npm i -g npm@">=4.0.0"
139

1410
install:
1511
- npm install
1612

1713
script:
18-
- npm test
14+
- npm run test:unit
1915

2016
deploy:
2117
provider: npm

babel.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module.exports = {
22
presets: ["@vue/app"],
3-
plugins: ["lodash"]
3+
plugins: ["lodash", "istanbul"]
44
};

package.json

+16-15
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
"build:core": "cross-env VUE_APP_FULL_BUNDLE=false vue-cli-service build --no-clean --target lib --name vfg-core src/index.js --report",
1212
"build:full": "cross-env VUE_APP_FULL_BUNDLE=true vue-cli-service build --no-clean --target lib --name vfg src/index.js --report",
1313
"lint": "vue-cli-service lint",
14-
"test:unit": "vue-cli-service test:unit --include ./tests/unit/setup.js",
15-
"coverall": "cat ./test/unit/coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
14+
"test:unit": "nyc vue-cli-service test:unit --include ./tests/unit/setup.js",
15+
"coverall": "cat ./tests/unit/coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
1616
"changelog": "conventional-changelog -i CHANGELOG.md -s",
1717
"changelog:full": "conventional-changelog -i CHANGELOG.md -s -r 0",
1818
"docs": "cd docs && gitbook serve",
@@ -56,15 +56,15 @@
5656
"license": "MIT",
5757
"dependencies": {},
5858
"devDependencies": {
59-
"@vue/cli-plugin-babel": "3.0.4",
60-
"@vue/cli-plugin-eslint": "3.0.4",
61-
"@vue/cli-plugin-unit-mocha": "3.0.4",
62-
"@vue/cli-service": "3.0.4",
63-
"@vue/eslint-config-prettier": "3.0.4",
59+
"@vue/cli-plugin-babel": "3.0.5",
60+
"@vue/cli-plugin-eslint": "3.0.5",
61+
"@vue/cli-plugin-unit-mocha": "3.0.5",
62+
"@vue/cli-service": "3.0.5",
63+
"@vue/eslint-config-prettier": "3.0.5",
6464
"@vue/test-utils": "1.0.0-beta.25",
65-
"babel-plugin-istanbul": "5.0.1",
65+
"babel-plugin-istanbul": "5.1.0",
6666
"babel-plugin-lodash": "3.3.4",
67-
"bumped": "0.10.10",
67+
"bumped": "0.10.11",
6868
"chai": "4.2.0",
6969
"cleave.js": "1.4.4",
7070
"conventional-changelog-cli": "2.0.5",
@@ -77,12 +77,12 @@
7777
"istanbul-instrumenter-loader": "3.0.1",
7878
"jquery": "3.3.1",
7979
"lodash-webpack-plugin": "0.11.5",
80-
"node-sass": "4.9.3",
80+
"node-sass": "4.9.4",
8181
"nouislider": "11.1.0",
82-
"nyc": "13.0.1",
82+
"nyc": "13.1.0",
8383
"pikaday": "1.7.0",
8484
"sass-loader": "7.1.0",
85-
"sinon": "6.3.5",
85+
"sinon": "7.0.0",
8686
"vue": "2.5.17",
8787
"vue-highlightjs": "1.3.3",
8888
"vue-markdown": "2.2.4",
@@ -203,7 +203,7 @@
203203
"arrowParens": "always"
204204
},
205205
"nyc": {
206-
"check-coverage": true,
206+
"check-coverage": false,
207207
"per-file": true,
208208
"include": [
209209
"src/**/*.{js,vue}"
@@ -216,10 +216,11 @@
216216
],
217217
"reporter": [
218218
"lcov",
219-
"text"
219+
"text",
220+
"text-summary"
220221
],
221222
"report-dir": "./tests/unit/coverage",
222-
"temp-directory": "./tests/unit/coverage/.nyc_output",
223+
"temp-dir": "./tests/unit/coverage/.nyc_output",
223224
"cache": true,
224225
"all": true
225226
},

src/fields/core/fieldUpload.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ export default {
2525
mixins: [abstractField],
2626
methods: {
2727
onChange($event) {
28-
if (isFunction(this.schema.onChanged)) {
28+
if (isFunction(this.fieldOptions.onChanged)) {
2929
// Schema has defined onChange method.
30-
this.schema.onChanged.call(this, this.model, this.schema, $event, this);
30+
this.fieldOptions.onChanged.call(this, this.model, this.schema, $event, this);
3131
}
3232
}
3333
}

tests/unit/specs/fields/fieldUpload.spec.js

+32
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,36 @@ describe("fieldUpload.vue", () => {
8484
});
8585
});
8686
});
87+
describe("check onChange methods", () => {
88+
let schema = {
89+
type: "upload",
90+
label: "Upload",
91+
inputName: "testupload",
92+
placeholder: "",
93+
readonly: false,
94+
required: false,
95+
disabled: false,
96+
fieldOptions: {
97+
multiple: true,
98+
accept: "image/*"
99+
}
100+
};
101+
let model = {};
102+
let input;
103+
104+
before(() => {
105+
createField({ schema, model });
106+
input = wrapper.find("input");
107+
schema.fieldOptions = { inputType: "file" };
108+
});
109+
110+
it("should contain an input text element", () => {
111+
schema.fieldOptions.onChanged = sinon.spy();
112+
wrapper.setProps({ schema: { ...schema } });
113+
114+
input.trigger("change", { $event: "MyEvent" });
115+
116+
expect(schema.fieldOptions.onChanged.calledOnce).to.be.true;
117+
});
118+
});
87119
});

vue.config.js

+11
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,17 @@ module.exports = {
4747
}
4848
]);
4949
config.plugin("lodash").use(LodashModuleReplacementPlugin);
50+
} else if (process.env.NODE_ENV === "test") {
51+
config.devtool("eval");
52+
config.module
53+
.rule("istanbul")
54+
.test(/\.(js|vue)$/)
55+
.enforce("post")
56+
.include.add(path.resolve(__dirname, "/src"))
57+
.end()
58+
.use("istanbul-instrumenter-loader")
59+
.loader("istanbul-instrumenter-loader")
60+
.options({ esModules: true });
5061
} else {
5162
config.resolve.alias.set("vue-form-generator", path.resolve("src"));
5263
}

0 commit comments

Comments
 (0)