Skip to content

Commit

Permalink
add a test for constant in unionAll
Browse files Browse the repository at this point in the history
Co-authored-by: mput <putintsev@gmail.com>
  • Loading branch information
Yngwarr and mput committed Feb 7, 2024
1 parent 0a11f09 commit 4f25e00
Showing 1 changed file with 73 additions and 4 deletions.
77 changes: 73 additions & 4 deletions sof-js/tests/5_constants.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@ const resources = [
{
resourceType: "Patient",
id: "pt2",
deceasedBoolean: true,
name: [{
family: "Johnson",
use: "usual"
}, {
family: "Menendez",
use: "old"
}]
}
];
Expand Down Expand Up @@ -79,17 +83,82 @@ describe("constant", () => {
title: "constant in where element",
view: {
constant: [{ name: "name_use", valueString: "official" }],
select: [
{
column: [{ name: "id", path: "id" }]
}
],
where: [{ path: "name.where(use = %name_use)" }]
},
expect: [{ id: "pt1" }]
});

add_test({
title: "constant in unionAll",
view: {
constant: [
{ name: "use1", valueString: "official" },
{ name: "use2", valueString: "usual" },
],
select: [{
unionAll: [
{
forEach: "name.where(use = %use1)",
column: [{
name: "name",
path: "family"
}]
}, {
forEach: "name.where(use = %use2)",
column: [{
name: "name",
path: "family"
}]
}
]
}]
},
expect: [
{ name: "Smith" },
{ name: "Block" },
{ name: "Johnson" }
]
})

add_test({
title: "integer constant",
view: {
constant: [{ name: "name_index", valueInteger: 1 }],
select: [
{
column: [
{ name: "id", path: "id" },
{ name: "name", path: "name.family.join(', ')" },
{
name: "official_name",
path: "name[%name_index].family"
}
]
}
]
},
expect: [
{ id: "pt1", official_name: "Smith" },
{ id: "pt2", official_name: "Menendez" }
]
});

add_test({
title: "boolean constant",
view: {
constant: [{ name: "is_deceased", valueInteger: true }],
select: [
{
column: [{ name: "id", path: "id" }]
}
],
where: [{ path: "name.where(use = %name_use)" }]
where: [{ path: "deceased.ofType(boolean) = %is_deceased" }]
},
expect: [{ id: "pt1", name: "Block, Smith" }]
expect: [{ id: "pt2" }]
});

add_throwing_test({
Expand All @@ -105,7 +174,7 @@ describe("constant", () => {
}
]
},
expectError: "undefined environment variable"
expectError: "undefined environment variable: wrong_name"
});

invalid_view({
Expand Down

0 comments on commit 4f25e00

Please sign in to comment.