1
+
1
2
import { expect } from "chai" ;
2
3
import React from "react" ;
3
4
import { Simulate } from "react-addons-test-utils" ;
@@ -135,6 +136,22 @@ describe("uiSchema", () => {
135
136
}
136
137
} ;
137
138
139
+ describe ( "file" , ( ) => {
140
+ const uiSchema = {
141
+ foo : {
142
+ "ui:widget" : "file"
143
+ }
144
+ } ;
145
+
146
+ it ( "should accept a uiSchema object" , ( ) => {
147
+ const { node} = createFormComponent ( { schema, uiSchema} ) ;
148
+
149
+ expect ( node . querySelectorAll ( "input[type=file]" ) )
150
+ . to . have . length . of ( 1 ) ;
151
+ } ) ;
152
+ } ) ;
153
+
154
+
138
155
describe ( "textarea" , ( ) => {
139
156
const uiSchema = {
140
157
foo : {
@@ -149,6 +166,7 @@ describe("uiSchema", () => {
149
166
. to . have . length . of ( 1 ) ;
150
167
} ) ;
151
168
169
+
152
170
it ( "should support formData" , ( ) => {
153
171
const { node} = createFormComponent ( { schema, uiSchema, formData : {
154
172
foo : "a"
@@ -883,6 +901,14 @@ describe("uiSchema", () => {
883
901
{ "ui:disabled" : true } ) ;
884
902
} ) ;
885
903
904
+ it ( "should disabled a file widget" , ( ) => {
905
+ const { node} = createFormComponent ( {
906
+ schema : { type : "string" , format : "data-url" } ,
907
+ uiSchema : { "ui:disabled" : true } } ) ;
908
+ expect ( node . querySelector ( "input[type=file]" ) . hasAttribute ( "disabled" ) )
909
+ . eql ( true ) ;
910
+ } ) ;
911
+
886
912
it ( "should disable a textarea widget" , ( ) => {
887
913
shouldBeDisabled ( "textarea" ,
888
914
{ type : "string" } ,
@@ -1048,6 +1074,15 @@ describe("uiSchema", () => {
1048
1074
{ "ui:readonly" : true } ) ;
1049
1075
} ) ;
1050
1076
1077
+ it ( "should mark as readonly a file widget" , ( ) => {
1078
+ // We mark a file widget as readonly by disabling it.
1079
+ const { node} = createFormComponent ( {
1080
+ schema : { type : "string" , format : "data-url" } ,
1081
+ uiSchema : { "ui:readonly" : true } } ) ;
1082
+ expect ( node . querySelector ( "input[type=file]" ) . hasAttribute ( "disabled" ) )
1083
+ . eql ( true ) ;
1084
+ } ) ;
1085
+
1051
1086
it ( "should mark as readonly a textarea widget" , ( ) => {
1052
1087
shouldBeReadonly ( "textarea" ,
1053
1088
{ type : "string" } ,
0 commit comments