1
1
import { expect } from "chai" ;
2
- import { createVueField , trigger } from "../util" ;
2
+ import { createVueField , trigger , checkAttribute } from "../util" ;
3
3
4
4
import Vue from "vue" ;
5
5
import FieldGoogleAddress from "src/fields/fieldGoogleAddress.vue" ;
@@ -19,8 +19,9 @@ describe("fieldGoogleAddress.vue", function() {
19
19
type : "text" ,
20
20
label : "Address" ,
21
21
model : "address" ,
22
- readonly : false ,
23
- placeholder : "Field placeholder"
22
+ autocomplete : "off" ,
23
+ placeholder : "Field placeholder" ,
24
+ readonly : false
24
25
} ;
25
26
let model = { address : "Paris, France" } ;
26
27
let input ;
@@ -37,9 +38,9 @@ describe("fieldGoogleAddress.vue", function() {
37
38
expect ( input ) . to . be . defined ;
38
39
expect ( input . type ) . to . be . equal ( "text" ) ;
39
40
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;
43
44
} ) ;
44
45
45
46
it ( "should contain the value" , ( done ) => {
@@ -49,21 +50,14 @@ describe("fieldGoogleAddress.vue", function() {
49
50
} ) ;
50
51
} ) ;
51
52
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" ] ;
60
56
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
+ } ) ;
67
61
} ) ;
68
62
} ) ;
69
63
0 commit comments