Skip to content

Commit

Permalink
Add validation test for view with missing resource
Browse files Browse the repository at this point in the history
  • Loading branch information
johngrimes committed Feb 23, 2024
1 parent a601913 commit e41f6e9
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 23 deletions.
50 changes: 27 additions & 23 deletions sof-js/tests/validation.test.js
Original file line number Diff line number Diff line change
@@ -1,61 +1,65 @@
import { describe } from "bun:test";
import { start_case, end_case, invalid_view, debug, add_throwing_test } from './test_helpers.js'

import { describe } from 'bun:test'
import { add_throwing_test, end_case, invalid_view, start_case } from './test_helpers.js'

let resources = [
{
resourceType: 'Patient',
name: [
{ family: 'F1.1' },
],
id: 'pt1'
name: [{ family: 'F1.1' }],
id: 'pt1',
},
{
resourceType: 'Patient',
id: 'pt2'
id: 'pt2',
},
]

start_case('validate', 'TBD', resources)

describe("validate", () => {

describe('validate', () => {
invalid_view({
title: 'empty',
view: {},
expectError: true
});
expectError: true,
})

invalid_view({
title: 'missing resource',
view: {
select: [{ column: [{ name: 'id', path: 'id' }] }],
},
expectError: true,
})

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

invalid_view({
title: 'wrong type in forEach',
view: {
resource: 'Patient',
status: 'active',
select: [{forEach: 1}]
select: [{ forEach: 1 }],
},
expectError: true
});
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"}]
select: [{ column: [{ name: 'id', path: 'id' }] }],
where: [{ path: 'name.family' }],
},
expectError: true
});
expectError: true,
})

end_case()
});
})
16 changes: 16 additions & 0 deletions tests/validate.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,22 @@
"view": {},
"expectError": true
},
{
"title": "missing resource",
"view": {
"select": [
{
"column": [
{
"name": "id",
"path": "id"
}
]
}
]
},
"expectError": true
},
{
"title": "wrong fhirpath",
"view": {
Expand Down

0 comments on commit e41f6e9

Please sign in to comment.