Skip to content

Commit

Permalink
[#199] turn 'error' in invalid_view tests into 'expectError'
Browse files Browse the repository at this point in the history
  • Loading branch information
Yngwarr committed Feb 19, 2024
1 parent e89eb10 commit 6b9562e
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 97 deletions.
19 changes: 2 additions & 17 deletions sof-js/tests/1_basic.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ test('columns', ()=>{

})


let resources = [
{
resourceType: 'Patient',
Expand Down Expand Up @@ -118,7 +117,6 @@ describe("basics", () => {
{id: 'pt3', last_name: null}
]


add_test({
title: 'two columns',
view: {
Expand All @@ -136,7 +134,6 @@ describe("basics", () => {
expect: expected
})


add_test({
title: 'two selects with columns',
view: {
Expand All @@ -156,7 +153,7 @@ describe("basics", () => {
resource: 'Patient',
status: 'active',
select: [{column: [{name: 'id', path: 'id'}]}],
where: [{path: 'active=true'}]
where: [{path: 'active = true'}]
},
expect: [{id: 'pt1'}]
})
Expand All @@ -167,12 +164,11 @@ describe("basics", () => {
resource: 'Patient',
status: 'active',
select: [{column: [{name: 'id', path: 'id'}]}],
where: [{path: 'active=false'}]
where: [{path: 'active = false'}]
},
expect: [{id: 'pt2'}]
})


add_test({
title: 'where as element',
view: {
Expand Down Expand Up @@ -206,16 +202,5 @@ describe("basics", () => {
expect: [{id: 'pt1'}]
})

add_throwing_test({
title: 'where with path resolving to not boolean',
view: {
resource: 'Patient',
status: 'active',
select: [{column: [{name: 'id', path: 'id'}]}],
where: [{path: "name.family"}]
},
expectError: true
})

end_case();
});
3 changes: 0 additions & 3 deletions sof-js/tests/2_fhirpath.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ describe("fhirpath", () => {
]
})


add_test({
title: 'exists',
view: {
Expand Down Expand Up @@ -228,7 +227,6 @@ describe("fhirpath", () => {
]
})


add_test({
title: 'string join',
view: {
Expand Down Expand Up @@ -271,7 +269,6 @@ describe("fhirpath", () => {
]
})


// are we sure about this?
add_test({
title: 'getResourceKey()',
Expand Down
17 changes: 0 additions & 17 deletions sof-js/tests/3_foreach.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,23 +185,6 @@ describe('foreach', () => {
expect: nested_result
});

// add_test({
// title: 'nested forEach: order',
// view: {
// resource: 'Patient',
// status: 'active',
// select: [
// {column: [{name: 'id', path: 'id'}]},
// {forEach: 'contact',
// select: [
// {forEach: 'person', column: [{name: 'name', path: 'name'}]},
// {column: [{name: 'contact_type', path: 'type'}]},
// ]}
// ]
// },
// expect: nested_result
// });

end_case();

})
4 changes: 2 additions & 2 deletions sof-js/tests/4_union.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ describe("union", () => {
]
},
expectError: true
})
});

// as per https://build.fhir.org/ig/FHIR/sql-on-fhir-v2/StructureDefinition-ViewDefinition.html#unionall-column-requirements
add_throwing_test({
Expand Down Expand Up @@ -365,7 +365,7 @@ describe("union", () => {
]
},
expectError: true
})
});

end_case()
});
Expand Down
3 changes: 2 additions & 1 deletion sof-js/tests/5_constants.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,8 @@ describe("constant", () => {
]
}
]
}
},
expectError: true
});

end_case();
Expand Down
64 changes: 36 additions & 28 deletions sof-js/tests/validation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,34 +17,42 @@ start_case('validate', 'TBD', resources)

describe("validate", () => {

invalid_view(
{
title: 'empty',
view: {},
error: 'structure'
});

invalid_view(
{
title: 'wrong fhirpath',
view: {
resource: 'Patient',
status: 'active',
select: [{forEach: '@@'}]
},
error: 'fhirpath'
})

invalid_view(
{
title: 'wrong type',
view: {
resource: 'Patient',
status: 'active',
select: [{forEach: 1}]
},
error: 'structure'
})
invalid_view({
title: 'empty',
view: {},
expectError: true
});

invalid_view({
title: 'wrong fhirpath',
view: {
resource: 'Patient',
status: 'active',
select: [{forEach: '@@'}]
},
expectError: true
});

invalid_view({
title: 'wrong type in forEach',
view: {
resource: 'Patient',
status: 'active',
select: [{forEach: 1}]
},
expectError: true
});

add_throwing_test({
title: 'where with path resolving to not boolean',
view: {
resource: 'Patient',
status: 'active',
select: [{column: [{name: 'id', path: 'id'}]}],
where: [{path: "name.family"}]
},
expectError: true
});

end_case()
});
3 changes: 1 addition & 2 deletions sof-js/tests/view_resource.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,9 @@ describe("view_resource", () => {
{ column: [{path: 'id', name: 'id'}] }
]
},
error: 'structure'
expectError: true
});


end_case()

});
27 changes: 2 additions & 25 deletions tests/basic.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@
],
"where": [
{
"path": "active=true"
"path": "active = true"
}
]
},
Expand All @@ -209,7 +209,7 @@
],
"where": [
{
"path": "active=false"
"path": "active = false"
}
]
},
Expand Down Expand Up @@ -299,29 +299,6 @@
"id": "pt1"
}
]
},
{
"title": "where with path resolving to not boolean",
"view": {
"resource": "Patient",
"status": "active",
"select": [
{
"column": [
{
"name": "id",
"path": "id"
}
]
}
],
"where": [
{
"path": "name.family"
}
]
},
"expectError": true
}
]
}
3 changes: 2 additions & 1 deletion tests/constant.json
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,8 @@
]
}
]
}
},
"expectError": true
}
]
}
2 changes: 1 addition & 1 deletion tests/view_resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
}
]
},
"error": "structure"
"expectError": true
}
]
}

0 comments on commit 6b9562e

Please sign in to comment.