11import { expect } from "chai" ;
2- import { createVueField , trigger } from "../util" ;
2+ import { createVueField , trigger , checkAttribute } from "../util" ;
33
44import Vue from "vue" ;
55import FieldGoogleAddress from "src/fields/fieldGoogleAddress.vue" ;
@@ -19,8 +19,9 @@ describe("fieldGoogleAddress.vue", function() {
1919 type : "text" ,
2020 label : "Address" ,
2121 model : "address" ,
22- readonly : false ,
23- placeholder : "Field placeholder"
22+ autocomplete : "off" ,
23+ placeholder : "Field placeholder" ,
24+ readonly : false
2425 } ;
2526 let model = { address : "Paris, France" } ;
2627 let input ;
@@ -37,9 +38,9 @@ describe("fieldGoogleAddress.vue", function() {
3738 expect ( input ) . to . be . defined ;
3839 expect ( input . type ) . to . be . equal ( "text" ) ;
3940 expect ( input . classList . contains ( "form-control" ) ) . to . be . true ;
40- expect ( input . placeholder ) . to . be . equal ( schema . placeholder ) ;
41- expect ( input . readOnly ) . to . be . false ;
42- expect ( input . disabled ) . to . be . false ;
41+ // expect(input.placeholder).to.be.equal(schema.placeholder);
42+ // expect(input.readOnly).to.be.false;
43+ // expect(input.disabled).to.be.false;
4344 } ) ;
4445
4546 it ( "should contain the value" , ( done ) => {
@@ -49,21 +50,14 @@ describe("fieldGoogleAddress.vue", function() {
4950 } ) ;
5051 } ) ;
5152
52- it ( "should set readOnly" , ( done ) => {
53- schema . readonly = true ;
54- vm . $nextTick ( ( ) => {
55- expect ( input . readOnly ) . to . be . true ;
56- schema . readonly = false ;
57- done ( ) ;
58- } ) ;
59- } ) ;
53+ describe ( "check optional attribute" , ( ) => {
54+ // name which attributes you want to test and that's it.
55+ let attributes = [ "autocomplete" , "disabled" , "placeholder" , "readonly" ] ;
6056
61- it ( "should set disabled" , ( done ) => {
62- field . disabled = true ;
63- vm . $nextTick ( ( ) => {
64- expect ( input . disabled ) . to . be . true ;
65- field . disabled = false ;
66- done ( ) ;
57+ attributes . forEach ( function ( name ) {
58+ it ( "should set " + name , function ( done ) {
59+ checkAttribute ( name , vm , input , field , schema , done ) ;
60+ } ) ;
6761 } ) ;
6862 } ) ;
6963
0 commit comments