@@ -37,7 +37,10 @@ import {
37
37
editorLocalization
38
38
} from "../../src/editorLocalization" ;
39
39
import { SurveyPropertyConditionEditor } from "../../src/propertyEditors/propertyConditionEditor" ;
40
- import { SurveyPropertyDefaultValueEditor } from "../../src/propertyEditors/propertyDefaultValueEditor" ;
40
+ import {
41
+ SurveyPropertyDefaultValueEditor ,
42
+ SurveyPropertySetEditor
43
+ } from "../../src/propertyEditors/propertyDefaultValueEditor" ;
41
44
import { SurveyPropertyCellsEditor } from "../../src/propertyEditors/propertyCellsEditor" ;
42
45
43
46
export default QUnit . module ( "PropertyEditorsTests" ) ;
@@ -1490,6 +1493,48 @@ QUnit.test("Triggers property editor and setvalue trigger", function(assert) {
1490
1493
) ;
1491
1494
} ) ;
1492
1495
1496
+ QUnit . test ( "'set' property editor" , function ( assert ) {
1497
+ Survey . Serializer . addProperty ( "survey" , {
1498
+ name : "region:set" ,
1499
+ choices : [ "Africa" , "Americas" , "Asia" , "Europe" , "Oceania" ]
1500
+ } ) ;
1501
+ var survey = createSurvey ( ) ;
1502
+ var setValueEditor = new SurveyPropertySetEditor (
1503
+ Survey . Serializer . findProperty ( "survey" , "region" )
1504
+ ) ;
1505
+ setValueEditor . object = survey ;
1506
+ setValueEditor . beforeShow ( ) ;
1507
+ var question = setValueEditor . koSurvey ( ) . getAllQuestions ( ) [ 0 ] ;
1508
+ assert . deepEqual ( question . choices . length , 5 , "There are 5 choices" ) ;
1509
+ Survey . Serializer . removeProperty ( "survey" , "region" ) ;
1510
+ } ) ;
1511
+
1512
+ QUnit . test ( "'set' property editor, get choices on callback, Bug#720" , function (
1513
+ assert
1514
+ ) {
1515
+ var choices = [ "Africa" , "Americas" , "Asia" , "Europe" , "Oceania" ] ;
1516
+ var callback = null ;
1517
+ Survey . Serializer . addProperty ( "survey" , {
1518
+ name : "region:set" ,
1519
+ choices : function ( obj , choicesCallback ) {
1520
+ callback = choicesCallback ;
1521
+ return [ ] ;
1522
+ }
1523
+ } ) ;
1524
+ var survey = createSurvey ( ) ;
1525
+ var setValueEditor = new SurveyPropertySetEditor (
1526
+ Survey . Serializer . findProperty ( "survey" , "region" )
1527
+ ) ;
1528
+ setValueEditor . object = survey ;
1529
+ setValueEditor . beforeShow ( ) ;
1530
+ var question = setValueEditor . koSurvey ( ) . getAllQuestions ( ) [ 0 ] ;
1531
+ assert . deepEqual ( question . choices . length , 0 , "There is no choices yet" ) ;
1532
+ callback ( choices ) ;
1533
+ question = setValueEditor . koSurvey ( ) . getAllQuestions ( ) [ 0 ] ;
1534
+ assert . deepEqual ( question . choices . length , 5 , "There are 5 choices now" ) ;
1535
+ Survey . Serializer . removeProperty ( "survey" , "region" ) ;
1536
+ } ) ;
1537
+
1493
1538
QUnit . test ( "Validators property editor" , function ( assert ) {
1494
1539
var survey = createSurvey ( ) ;
1495
1540
var validator = new Survey . NumericValidator ( 10 , 100 ) ;
0 commit comments