-
Notifications
You must be signed in to change notification settings - Fork 531
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: unit test for fieldGoogleAddress
- Loading branch information
Showing
3 changed files
with
146 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,65 @@ | ||
var wsConfig = require("./webpack.test.config"); | ||
|
||
module.exports = function(config) { | ||
var settings = { | ||
// base path that will be used to resolve all patterns (eg. files, exclude) | ||
basePath: "", | ||
var settings = { | ||
// base path that will be used to resolve all patterns (eg. files, exclude) | ||
basePath: "", | ||
|
||
browsers: ["PhantomJS"], | ||
browsers: ["PhantomJS"], | ||
|
||
reporters: ["spec", "coverage"], | ||
reporters: ["spec", "coverage"], | ||
|
||
frameworks: ["mocha", "chai", "sinon-chai"], | ||
frameworks: ["mocha", "chai", "sinon-chai"], | ||
|
||
files: [ | ||
"https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.3/jquery.js", | ||
"https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.13.0/moment.min.js", | ||
"https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/js/bootstrap.js", | ||
"https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.10.0/js/bootstrap-select.min.js", | ||
"https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/js/bootstrap-datetimepicker.min.js", | ||
"https://cdnjs.cloudflare.com/ajax/libs/spectrum/1.8.0/spectrum.js", | ||
"https://cdnjs.cloudflare.com/ajax/libs/jquery.maskedinput/1.4.1/jquery.maskedinput.js", | ||
"https://cdnjs.cloudflare.com/ajax/libs/ion-rangeslider/2.1.4/js/ion.rangeSlider.js", | ||
"https://rawgit.com/monterail/vue-multiselect/master/lib/vue-multiselect.min.js", | ||
"https://rawgit.com/nosir/cleave.js/master/dist/cleave.min.js", | ||
"https://nosir.github.io/cleave.js/lib/cleave-phone.i18n.js", | ||
"https://cdnjs.cloudflare.com/ajax/libs/noUiSlider/8.5.1/nouislider.js", | ||
"https://cdnjs.cloudflare.com/ajax/libs/pikaday/1.4.0/pikaday.min.js", | ||
files: [ | ||
"https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.3/jquery.js", | ||
"https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.13.0/moment.min.js", | ||
"https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/js/bootstrap.js", | ||
"https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.10.0/js/bootstrap-select.min.js", | ||
"https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/js/bootstrap-datetimepicker.min.js", | ||
"https://cdnjs.cloudflare.com/ajax/libs/spectrum/1.8.0/spectrum.js", | ||
"https://cdnjs.cloudflare.com/ajax/libs/jquery.maskedinput/1.4.1/jquery.maskedinput.js", | ||
"https://cdnjs.cloudflare.com/ajax/libs/ion-rangeslider/2.1.4/js/ion.rangeSlider.js", | ||
"https://rawgit.com/monterail/vue-multiselect/master/lib/vue-multiselect.min.js", | ||
"https://rawgit.com/nosir/cleave.js/master/dist/cleave.min.js", | ||
"https://nosir.github.io/cleave.js/lib/cleave-phone.i18n.js", | ||
"https://cdnjs.cloudflare.com/ajax/libs/noUiSlider/8.5.1/nouislider.js", | ||
"https://cdnjs.cloudflare.com/ajax/libs/pikaday/1.4.0/pikaday.min.js", | ||
"https://maps.googleapis.com/maps/api/js?key=AIzaSyCEz-sX9bRJorDS-D_JL0JkZVZe2gzoUMw&libraries=places", | ||
|
||
"./index.js" | ||
], | ||
"./index.js" | ||
], | ||
|
||
exclude: [], | ||
exclude: [], | ||
|
||
preprocessors: { | ||
"./index.js": ["webpack", "sourcemap"] | ||
}, | ||
preprocessors: { | ||
"./index.js": ["webpack", "sourcemap"] | ||
}, | ||
|
||
webpack: wsConfig, | ||
webpack: wsConfig, | ||
|
||
webpackMiddleware: { | ||
noInfo: true | ||
}, | ||
webpackMiddleware: { | ||
noInfo: true | ||
}, | ||
|
||
port: 9876, | ||
port: 9876, | ||
|
||
colors: true, | ||
colors: true, | ||
|
||
logLevel: config.LOG_INFO, | ||
logLevel: config.LOG_INFO, | ||
|
||
autoWatch: false, | ||
autoWatch: false, | ||
|
||
singleRun: true, | ||
singleRun: true, | ||
|
||
coverageReporter: { | ||
dir: "./coverage", | ||
reporters: [ | ||
{ type: "lcov", subdir: "." }, | ||
{ type: "text-summary" } | ||
] | ||
} | ||
} | ||
coverageReporter: { | ||
dir: "./coverage", | ||
reporters: [ | ||
{ type: "lcov", subdir: "." }, | ||
{ type: "text-summary" } | ||
] | ||
} | ||
} | ||
|
||
config.set(settings); | ||
config.set(settings); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import { expect } from "chai"; | ||
import { createVueField, trigger } from "../util"; | ||
|
||
import Vue from "vue"; | ||
import FieldGoogleAddress from "src/fields/fieldGoogleAddress.vue"; | ||
|
||
Vue.component("FieldGoogleAddress", FieldGoogleAddress); | ||
|
||
let el, vm, field; | ||
|
||
function createField(schema = {}, model = null, disabled = false, options) { | ||
[ el, vm, field ] = createVueField("fieldGoogleAddress", schema, model, disabled, options); | ||
} | ||
|
||
describe("fieldGoogleAddress.vue", () => { | ||
|
||
describe("check template", () => { | ||
let schema = { | ||
type: "text", | ||
label: "Address", | ||
model: "address", | ||
readonly: false, | ||
placeholder: "Field placeholder" | ||
}; | ||
let model = { address: "Paris, France" }; | ||
let input; | ||
|
||
before( () => { | ||
createField(schema, model, false); | ||
input = el.getElementsByTagName("input")[0]; | ||
}); | ||
|
||
it("should contain an input text element", () => { | ||
expect(field).to.be.exist; | ||
expect(field.$el).to.be.exist; | ||
|
||
expect(input).to.be.defined; | ||
expect(input.type).to.be.equal("text"); | ||
expect(input.classList.contains("form-control")).to.be.true; | ||
expect(input.placeholder).to.be.equal(schema.placeholder); | ||
expect(input.readOnly).to.be.false; | ||
expect(input.disabled).to.be.false; | ||
}); | ||
|
||
it("should contain the value", (done) => { | ||
vm.$nextTick( () => { | ||
expect(input.value).to.be.equal("Paris, France"); | ||
done(); | ||
}); | ||
}); | ||
|
||
it("should set readOnly", (done) => { | ||
schema.readonly = true; | ||
vm.$nextTick( () => { | ||
expect(input.readOnly).to.be.true; | ||
schema.readonly = false; | ||
done(); | ||
}); | ||
}); | ||
|
||
it("should set disabled", (done) => { | ||
field.disabled = true; | ||
vm.$nextTick( () => { | ||
expect(input.disabled).to.be.true; | ||
field.disabled = false; | ||
done(); | ||
}); | ||
}); | ||
|
||
it("input value should be the model value after changed", (done) => { | ||
model.address = "Rome, Italy"; | ||
vm.$nextTick( () => { | ||
expect(input.value).to.be.equal("Rome, Italy"); | ||
done(); | ||
}); | ||
|
||
}); | ||
|
||
it("model value should be the input value if changed", (done) => { | ||
input.value = "Budapest, Hungary"; | ||
trigger(input, "change"); | ||
|
||
vm.$nextTick( () => { | ||
expect(model.address).to.be.equal("Budapest, Hungary"); | ||
done(); | ||
}); | ||
|
||
}); | ||
|
||
/* | ||
TODO: | ||
1. check HTML list if typing | ||
2. check geolocate called if input got focus | ||
3. check onPlaceChanged called | ||
*/ | ||
|
||
}); | ||
|
||
}); |