Skip to content

Commit 59aaf2b

Browse files
author
Lionel Bijaoui
committed
Progress on test
1 parent 166ee43 commit 59aaf2b

21 files changed

+729
-771
lines changed

package-lock.json

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"docs": "cd docs && gitbook serve",
1919
"unit": "karma start test/unit/karma.conf.js",
2020
"unit3": "cross-env NODE_ENV=test mocha-webpack --watch --webpack-config build/webpack.test.config.js --require test/unit/setup.js test/unit/specs/**/*.spec.js",
21+
"unit5": "cross-env NODE_ENV=test mocha-webpack --webpack-config build/webpack.test.config.js --require test/unit/setup.js test/unit/specs/**/*.spec.js",
2122
"e2e": "node test/e2e/runner.js",
2223
"pretest": "npm run lint",
2324
"test": "npm run unit",
@@ -77,6 +78,7 @@
7778
"fecha": "2.3.3",
7879
"file-loader": "1.1.9",
7980
"inject-loader": "3.0.1",
81+
"ion-rangeslider": "^2.2.0",
8082
"isparta-loader": "2.0.0",
8183
"istanbul-instrumenter-loader": "^3.0.0",
8284
"jquery": "^3.3.1",
@@ -90,8 +92,10 @@
9092
"mocha-webpack": "^1.0.1",
9193
"nightwatch": "^0.9.19",
9294
"node-sass": "4.7.2",
95+
"nouislider": "^11.0.3",
9396
"nyc": "^11.4.1",
9497
"phantomjs-prebuilt": "2.1.16",
98+
"pikaday": "^1.7.0",
9599
"prettier": "1.10.2",
96100
"pug": "2.0.0-rc.4",
97101
"pug-loader": "2.3.0",

src/fields/optional/fieldGoogleAddress.vue

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { isFunction } from "lodash";
1515
export default {
1616
mixins: [abstractField],
1717
18-
data: function() {
18+
data() {
1919
return {
2020
// google autocomplete object
2121
autocomplete: "",
@@ -34,15 +34,22 @@ export default {
3434
},
3535
3636
mounted() {
37-
this.$nextTick(function() {
38-
if (window.google && window.google.maps && window.google.maps.places && window.google.maps.places.Autocomplete) {
37+
this.$nextTick(() => {
38+
if (
39+
window.google &&
40+
window.google.maps &&
41+
window.google.maps.places &&
42+
window.google.maps.places.Autocomplete
43+
) {
3944
this.autocomplete = new google.maps.places.Autocomplete(this.$el, {
4045
types: ["geocode"]
4146
});
4247
4348
this.autocomplete.addListener("place_changed", this.pipeAddress);
4449
} else {
45-
console.warn("Google Maps API is missing. Please add https://maps.googleapis.com/maps/api/js?key=YOUR_KEY&libraries=places script in the HTML head section!");
50+
console.warn(
51+
"Google Maps API is missing. Please add https://maps.googleapis.com/maps/api/js?key=YOUR_KEY&libraries=places script in the HTML head section!"
52+
);
4653
}
4754
});
4855
},
@@ -52,7 +59,7 @@ export default {
5259
* Look up places and dispatch an event.
5360
* @return void
5461
*/
55-
pipeAddress: function() {
62+
pipeAddress() {
5663
let place = this.autocomplete.getPlace();
5764
if (place) {
5865
this.value = place.formatted_address;
@@ -68,15 +75,16 @@ export default {
6875
}
6976
7077
// Call event in schema
71-
if (isFunction(this.schema.onPlaceChanged)) this.schema.onPlaceChanged(this.value, data, place, this.model, this.schema);
78+
if (isFunction(this.schema.onPlaceChanged))
79+
this.schema.onPlaceChanged(this.value, data, place, this.model, this.schema);
7280
}
7381
},
7482
7583
/**
7684
* Get the user location.
7785
* @return void
7886
*/
79-
geolocate: function() {
87+
geolocate() {
8088
if (navigator.geolocation) {
8189
navigator.geolocation.getCurrentPosition(position => {
8290
let geolocation = {
@@ -96,7 +104,3 @@ export default {
96104
}
97105
};
98106
</script>
99-
100-
<style lang="scss">
101-
102-
</style>

src/fields/optional/fieldNoUiSlider.vue

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div class="slider" :disabled="disabled" :class="{ 'contain-pips': containPips, 'contain-tooltip': containTooltip }"></div>
2+
<div class="slider" :disabled="disabled" :class="{ 'contain-pips': containPips, 'contain-tooltip': containTooltip }"></div>
33
</template>
44

55
<script>
@@ -70,7 +70,7 @@ export default {
7070
},
7171
7272
mounted() {
73-
this.$nextTick(function() {
73+
this.$nextTick(() => {
7474
if (window.noUiSlider) {
7575
this.slider = this.$el;
7676
window.noUiSlider.create(
@@ -85,7 +85,9 @@ export default {
8585
);
8686
this.slider.noUiSlider.on("change", this.onChange.bind(this));
8787
} else {
88-
console.warn("noUiSlider is missing. Please download from https://github.com/leongersen/noUiSlider and load the script and CSS in the HTML head section!");
88+
console.warn(
89+
"noUiSlider is missing. Please download from https://github.com/leongersen/noUiSlider and load the script and CSS in the HTML head section!"
90+
);
8991
}
9092
});
9193
},

test/unit/specs/VueFormGenerator.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,10 +741,10 @@ describe("VueFormGenerator.vue", () => {
741741

742742
before(() => {
743743
createFormGenerator({ schema, model, options: { validateAfterLoad: true } });
744-
form = wrapper.vm.$refs.form;
745744
});
746745

747746
it("should be validation error at mounted()", () => {
747+
form = wrapper.vm.$refs.form;
748748
expect(form.errors).to.be.length(1);
749749
});
750750

test/unit/specs/fields/abstractField.spec.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ describe("abstractField.vue", () => {
7474

7575
it("should set new value to model if value changed", () => {
7676
field.value = "Foo Bar";
77+
7778
expect(model.user.name).to.be.equal("Foo Bar");
7879
});
7980
});
@@ -99,6 +100,7 @@ describe("abstractField.vue", () => {
99100

100101
it("should set new value to model if value changed", () => {
101102
field.value = "Foo Bar";
103+
102104
expect(model.user.name.first).to.be.equal("Foo Bar");
103105
});
104106
});
@@ -119,14 +121,17 @@ describe("abstractField.vue", () => {
119121

120122
it.skip("should be called the schema.get function", () => {
121123
expect(field).to.be.exist;
124+
122125
field.schema.get.reset();
126+
123127
expect(field.value).to.be.equal("John Smith");
124128
expect(field.schema.get.calledOnce).to.be.true;
125129
});
126130

127131
it("should set new value to model if value changed", () => {
128132
field.schema.set.reset();
129133
field.value = "John Roe";
134+
130135
expect(field.schema.set.calledOnce).to.be.true;
131136
expect(field.schema.set.calledWith(model, "John Roe")).to.be.true;
132137
});
@@ -157,6 +162,7 @@ describe("abstractField.vue", () => {
157162

158163
it("should set the formatted value to model", () => {
159164
field.value = "Foo Bar";
165+
160166
expect(model.name).to.be.equal("!!Foo Bar!!");
161167
});
162168
});
@@ -177,6 +183,7 @@ describe("abstractField.vue", () => {
177183
it("should called once the schema.onChanged", () => {
178184
schema.onChanged.resetHistory();
179185
field.value = "Jane Doe";
186+
180187
expect(schema.onChanged.calledOnce).to.be.true;
181188
});
182189
});
@@ -200,12 +207,14 @@ describe("abstractField.vue", () => {
200207

201208
it("should not call validate function after value changed", () => {
202209
model.name = "Jane Doe";
210+
203211
expect(field.validate.callCount).to.be.equal(0);
204212
});
205213

206214
it("should call validate function after value changed", () => {
207215
options.validateAfterChanged = true;
208216
field.value = "Jane Roe";
217+
209218
expect(field.validate.callCount).to.be.equal(1);
210219
});
211220
});
@@ -227,6 +236,7 @@ describe("abstractField.vue", () => {
227236
it("should call schema validator", () => {
228237
schema.validator.resetHistory();
229238
field.validate();
239+
230240
expect(schema.validator.calledOnce).to.be.true;
231241
expect(schema.validator.calledWith(field.value, schema, model)).to.be.true;
232242
});
@@ -249,6 +259,7 @@ describe("abstractField.vue", () => {
249259
it("should not call schema validator", () => {
250260
schema.validator.resetHistory();
251261
field.validate();
262+
252263
expect(schema.validator.callCount).to.be.equal(0);
253264
});
254265
});
@@ -271,6 +282,7 @@ describe("abstractField.vue", () => {
271282
it("should not call schema validator", () => {
272283
schema.validator.resetHistory();
273284
field.validate();
285+
274286
expect(schema.validator.callCount).to.be.equal(0);
275287
});
276288
});
@@ -321,6 +333,7 @@ describe("abstractField.vue", () => {
321333
it("should called once the schema.onValidated", () => {
322334
schema.onValidated.resetHistory();
323335
let res = field.validate();
336+
324337
expect(res).to.be.an.instanceof(Array);
325338
expect(res.length).to.be.equal(1);
326339
expect(res[0]).to.be.equal("Validation error!");
@@ -352,6 +365,7 @@ describe("abstractField.vue", () => {
352365
it("should return empty array", () => {
353366
onValidated.resetHistory();
354367
let res = field.validate();
368+
355369
expect(res).to.be.an.instanceof(Array);
356370
expect(res.length).to.be.equal(0);
357371

@@ -362,6 +376,7 @@ describe("abstractField.vue", () => {
362376
it("should not call 'onValidated'", () => {
363377
onValidated.resetHistory();
364378
let res = field.validate(true);
379+
365380
expect(res).to.be.an.instanceof(Array);
366381
expect(res.length).to.be.equal(0);
367382

@@ -372,6 +387,7 @@ describe("abstractField.vue", () => {
372387
model.name = "Al";
373388
onValidated.resetHistory();
374389
let res = field.validate();
390+
375391
expect(res).to.be.an.instanceof(Array);
376392
expect(res.length).to.be.equal(1);
377393
expect(res[0]).to.be.equal("The length of text is too small! Current: 2, Minimum: 3");
@@ -400,12 +416,14 @@ describe("abstractField.vue", () => {
400416

401417
it("should be an empty array", () => {
402418
field.clearValidationErrors();
419+
403420
expect(field.errors).to.be.not.undefined;
404421
expect(field.errors).to.be.length(0);
405422
});
406423

407424
it("should contain one error string", () => {
408425
field.validate();
426+
409427
expect(field.errors).to.be.length(1);
410428
expect(field.errors[0]).to.be.equal("Validation error!");
411429
});
@@ -430,11 +448,13 @@ describe("abstractField.vue", () => {
430448

431449
it("should return slugified label, if no inputName", () => {
432450
delete schema.inputName;
451+
433452
expect(field.getFieldID(schema)).to.be.equal("first-name");
434453
});
435454

436455
it("should return slugified model name, if no inputName or label", () => {
437456
delete schema.label;
457+
438458
expect(field.getFieldID(schema)).to.be.equal("user-model");
439459
});
440460
});

test/unit/specs/fields/fieldCheckbox.spec.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ describe("FieldCheckbox.vue", () => {
5050
it("input value should be the model value after changed", () => {
5151
model.status = false;
5252
wrapper.update();
53+
5354
expect(input.element.checked).to.be.false;
5455
});
5556

0 commit comments

Comments
 (0)