Skip to content

Commit

Permalink
added and replaced drishti tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Martijn van de Rijdt committed Mar 28, 2013
1 parent 94559c6 commit 0b4434d
Show file tree
Hide file tree
Showing 6 changed files with 282 additions and 99 deletions.
132 changes: 94 additions & 38 deletions drishti/mocks/instances.mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,39 @@ var mockInstances =
"bind_type": "eligible_couple",
"default_bind_path": "/model/instance/EC_Registration_EngKan_Final/",
"fields": [
{
"name": "uuid",
"bind": "/model/instance/EC_Registration_EngKan_Final/formhub/uuid"
},
{
"name": "today"
},
{
"name": "phc",
"bind": "ec_village_phc"
"bind": "/model/instance/EC_Registration_EngKan_Final/ec_village_phc"
},
{
"name": "sc",
"bind": "ec_village_subcenter",
"bind": "/model/instance/EC_Registration_EngKan_Final/ec_village_subcenter",
"source": "eligible_couple.subCenter",
"value": "bherya_a"
},
{
"name": "village",
"bind": "ec_village",
"bind": "/model/instance/EC_Registration_EngKan_Final/ec_village",
"value": "basavanapura"
},
{
"name": "household_number",
"bind": "hh_number"
"bind": "/model/instance/EC_Registration_EngKan_Final/hh_number"
},
{
"name": "household_address",
"bind": "hh_address"
"bind": "/model/instance/EC_Registration_EngKan_Final/hh_address"
},
{
"name": "head_of_household",
"bind": "headofhousehold",
"bind": "/model/instance/EC_Registration_EngKan_Final/headofhousehold",
"source": "eligible_couple.headOfHousehold",
"value": "Suresh"
},
Expand All @@ -47,19 +54,19 @@ var mockInstances =
},
{
"name": "woman_name",
"bind": "woman_name2",
"bind": "/model/instance/EC_Registration_EngKan_Final/woman_name2",
"source": "eligible_couple.wifeName",
"value": "Kavitha"
},
{
"name": "aadhar_number"
"name": "aadhaar_number"
},
{
"name": "woman_age"
},
{
"name": "woman_dob",
"bind": "woman_date_of_birth"
"bind": "/model/instance/EC_Registration_EngKan_Final/woman_date_of_birth"
},
{
"name": "husband_name",
Expand All @@ -68,18 +75,18 @@ var mockInstances =
},
{
"name": "phone_number",
"bind": "phone_no"
"bind": "/model/instance/EC_Registration_EngKan_Final/phone_no"
},
{
"name": "phone_owner"
},
{
"name": "alternate_phone_number",
"bind": "phone_no2"
"bind": "/model/instance/EC_Registration_EngKan_Final/phone_no2"
},
{
"name": "alternate_phone_owner",
"bind": "phone_owner2"
"bind": "/model/instance/EC_Registration_EngKan_Final/phone_owner2"
},
{
"name": "economic_status",
Expand All @@ -98,99 +105,119 @@ var mockInstances =
"value": "sc"
},
{
"name": "educational_level"
"name": "education_level"
},
{
"name": "number_of_pregnancies",
"bind": "num_pregnancies",
"bind": "/model/instance/EC_Registration_EngKan_Final/num_pregnancies",
"source": "eligible_couple.pregnancies",
"value": "1"
},
{
"name": "number_of_live_births",
"bind": "num_livebirths"
"bind": "/model/instance/EC_Registration_EngKan_Final/num_livebirths"
},
{
"name": "number_of_abortions",
"bind": "num_abortions"
"bind": "/model/instance/EC_Registration_EngKan_Final/num_abortions"
},
{
"name": "number_of_spontaneous_abortions",
"bind": "num_abortions_spontaneous"
"bind": "/model/instance/EC_Registration_EngKan_Final/num_abortions_spontaneous"
},
{
"name": "number_of_induced_abortions",
"bind": "num_abortions_induced"
"bind": "/model/instance/EC_Registration_EngKan_Final/num_abortions_induced"
},
{
"name": "number_of_stillbirths",
"bind": "num_stillbirths"
"bind": "/model/instance/EC_Registration_EngKan_Final/num_stillbirths"
},
{
"name": "number_of_living_children",
"bind": "num_livingchildren"
"bind": "/model/instance/EC_Registration_EngKan_Final/num_livingchildren"
},
{
"name": "number_of_living_male_children",
"bind": "num_livingchildren_male"
"bind": "/model/instance/EC_Registration_EngKan_Final/num_livingchildren_male"
},
{
"name": "number_of_living_female_children",
"bind": "num_livingchildren_female"
"bind": "/model/instance/EC_Registration_EngKan_Final/num_livingchildren_female"
},
{
"name": "is_youngest_under_two",
"bind": "youngestchild_under2"
"bind": "/model/instance/EC_Registration_EngKan_Final/youngestchild_under2"
},
{
"name": "youngest_childs_dob",
"bind": "child_under2_birthdate"
"bind": "/model/instance/EC_Registration_EngKan_Final/age_youngestchild"
},
{
"name": "fp_method",
"bind": "familyplanning_method",
"bind": "/model/instance/EC_Registration_EngKan_Final/familyplanning_method",
"source": "eligible_couple.currentMethod",
"value": "none"
},
{
"name": "fp_method",
"bind": "familyplanning_method_1",
"bind": "/model/instance/EC_Registration_EngKan_Final/familyplanning_method_1",
"source": "eligible_couple.currentMethod",
"value": "none"
},
{
"name": "fp_method",
"bind": "familyplanning_method_other",
"bind": "/model/instance/EC_Registration_EngKan_Final/familyplanning_method_other",
"source": "eligible_couple.currentMethod",
"value": "none"
},
{
"name": "place_where_iud_given",
"bind": "iud_place"
"bind": "/model/instance/EC_Registration_EngKan_Final/iud_place"
},
{
"name": "fp_start_date",
"bind": "date_familyplanningstart",
"bind": "/model/instance/EC_Registration_EngKan_Final/date_familyplanningstart",
"source": "eligible_couple.familyPlanningMethodChangeDate",
"value": "---"
},
{
"name": "fp_start_date",
"bind": "date_familyplanningstart",
"source": "eligible_couple.familyPlanningMethodChangeDate",
"value": "---"
"name": "threemonths_from_sterilization_date",
"bind": "/model/instance/EC_Registration_EngKan_Final/male_sterilizaton_group/threemonths_from_sterilization_date"
},
{
"name": "male_sterilization_message",
"bind": "/model/instance/EC_Registration_EngKan_Final/male_sterilizaton_group/male_sterilization_message"
},
{
"name": "number_of_condoms_supplied",
"bind": "num_condoms"
"bind": "/model/instance/EC_Registration_EngKan_Final/num_condoms"
},
{
"name": "number_of_ocp_strips_supplied",
"bind": "num_ocp_cycles"
"bind": "/model/instance/EC_Registration_EngKan_Final/num_ocp_cycles"
},
{
"name": "number_of_centchroman_strips_supplied",
"bind": "num_centchroman_pills"
"bind": "/model/instance/EC_Registration_EngKan_Final/num_centchroman_pills"
},
{
"name": "abortion_risk"
},
{
"name": "parity_risk_priority"
},
{
"name": "age_risk_priority"
},
{
"name": "youngchild_risk_priority"
},
{
"name": "would_be_high_risk"
},
{
"name": "would_be_high_risk_reason"
},
{
"name": "is_high_priority",
Expand All @@ -201,6 +228,21 @@ var mockInstances =
"name": "high_priority_reason",
"source": "eligible_couple.highPriorityReason",
"value": " "
},
{
"name": "message2"
},
{
"name": "message3"
},
{
"name": "instanceID",
"bind": "/model/instance/EC_Registration_EngKan_Final/meta/instanceID",
"value": "a"
},
{
"name": "deprecatedID",
"bind": "/model/instance/EC_Registration_EngKan_Final/meta/deprecatedID"
}
]
}
Expand Down Expand Up @@ -240,6 +282,7 @@ var mockInstances =
{
"name": "w1",
"bind": "/model/instance/thedata/someweights/w1",
"value": "2"
},
{
"name": "w2",
Expand All @@ -248,12 +291,16 @@ var mockInstances =
{
"name": "w.3",
"bind": "/model/instance/thedata/someweights/w.3",
},
{
"name": "deprecatedID",
"bind": "/model/instance/thedata/meta/deprecatedID"
}
],
"sub_forms" : [
{
"bind_type": "repeatGroup",
"default_bind_path": "/model/instance/thedata/repeatGroup",
"default_bind_path": "/model/instance/thedata/repeatGroup/",
"count_field_name": null,
"meta_fields" : [],
"fields":[
Expand All @@ -263,7 +310,16 @@ var mockInstances =
],
"instances":[
{
"nodeC": "some value"
"nodeC": "first value"
},
{
"nodeC": "second value"
},
{
"nodeC": "third value"
},
{
"nodeC": "fourth value"
}
]
}
Expand Down
8 changes: 4 additions & 4 deletions js_tests/SpecRunner_drishti.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@

<!-- include library files here... -->
<script type="text/javascript" src="../public/libraries/jquery.min.js"></script>
<script type="text/javascript" src="../public/libraries/modernizr.min.js"></script>
<script type="text/javascript" src="../public/libraries/xpathjs_javarosa/build/xpathjs_javarosa.min.js"></script>

<!-- include mock files here ... -->
<script type="text/javascript" src="mocks/transform.mock.js"></script>
<script type="text/javascript" src="../drishti/mocks/transforms.mock.js"></script>
<script type="text/javascript" src="../drishti/mocks/instances.mock.js"></script>
<script type="text/javascript" src="mocks/json_drishti.mock.js"></script>

<!-- include source files here... -->
<script type="text/javascript" src="../src/js/helpers.js"></script>
<script type="text/javascript" src="../src/js/storage_drishti.js"></script>
<script type="text/javascript" src="../src/js/form.js"></script>

<!-- include spec files here... -->
<script type="text/javascript" src="utils/test_utils.js"></script>
<script type="text/javascript" src="specs/transform.spec.js"></script>
<script type="text/javascript" src="specs/json_drishti.spec.js"></script>

<script type="text/javascript">
(function() {
Expand Down
14 changes: 14 additions & 0 deletions js_tests/mocks/json_drishti.mock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
var $fakeInstance;

function setFakeInstance(formName){
$fakeInstance = $($.parseXML(mockForms2[formName].xml_model));
}

function getFakeInstanceXML(includeTemplates){
var $docRoot = $fakeInstance.find('instance>*:first'),
$dataClone = $docRoot.clone();
if (includeTemplates === false){
$dataClone.find('[template]').remove();
}
return $dataClone;
}
Loading

0 comments on commit 0b4434d

Please sign in to comment.