Skip to content

Commit

Permalink
Update boundary function JS definition
Browse files Browse the repository at this point in the history
  • Loading branch information
johngrimes committed Feb 22, 2024
1 parent d566d0d commit d009569
Showing 1 changed file with 136 additions and 49 deletions.
185 changes: 136 additions & 49 deletions sof-js/tests/fn_boundary.test.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,43 @@
import { describe } from "bun:test";
import { add_test, end_case, start_case } from "./test_helpers";
import { describe } from 'bun:test'
import { add_test, end_case, start_case } from './test_helpers.js'

const resources = [
{
resourceType: 'Observation',
id: 'o1',
code: { text: 'code' },
status: 'final',
valueQuantity: { value: 1.0 }
valueQuantity: { value: 1.0 },
},
{
resourceType: 'Observation',
id: 'o2',
code: { text: 'code' },
status: 'final',
valueDateTime: '2010-10-10'
valueDateTime: '2010-10-10',
},
{
resourceType: 'Observation',
id: 'o3',
code: { text: 'code' },
status: 'final'
}
];
status: 'final',
},
{
resourceType: 'Observation',
id: 'o4',
code: { text: 'code' },
valueTime: '12:34',
},
{
resourceType: 'Patient',
id: 'p1',
birthDate: '1970-06',
},
]

start_case('fn_boundary', 'TBD', resources);
start_case('fn_boundary', 'TBD', resources)

describe('boundary functions', () => {
describe('boundary tests', () => {
add_test({
title: 'decimal lowBoundary',
view: {
Expand All @@ -38,18 +49,19 @@ describe('boundary functions', () => {
{ name: 'id', path: 'id' },
{
name: 'decimal',
path: 'value.ofType(Quantity).value.lowBoundary()'
}
]
}
]
path: 'value.ofType(Quantity).value.lowBoundary()',
},
],
},
],
},
expect: [
{ id: 'o1', decimal: 0.95 },
{ id: 'o2', decimal: null },
{ id: 'o3', decimal: null },
]
});
{ id: 'o4', decimal: null },
],
})

add_test({
title: 'decimal highBoundary',
Expand All @@ -62,18 +74,19 @@ describe('boundary functions', () => {
{ name: 'id', path: 'id' },
{
name: 'decimal',
path: 'value.ofType(Quantity).value.highBoundary()'
}
]
}
]
path: 'value.ofType(Quantity).value.highBoundary()',
},
],
},
],
},
expect: [
{ id: 'o1', decimal: 1.05 },
{ id: 'o2', decimal: null },
{ id: 'o3', decimal: null },
]
});
{ id: 'o4', decimal: null },
],
})

add_test({
title: 'datetime lowBoundary',
Expand All @@ -84,20 +97,18 @@ describe('boundary functions', () => {
{
column: [
{ name: 'id', path: 'id' },
{
name: 'datetime',
path: 'value.ofType(DateTime).lowBoundary()'
}
]
}
]
{ name: 'datetime', path: 'value.ofType(dateTime).lowBoundary()' },
],
},
],
},
expect: [
{ id: 'o1', decimal: null },
{ id: 'o2', decimal: '2010-10-10T00:00:00.000+14:00' },
{ id: 'o3', decimal: null },
]
});
{ id: 'o1', datetime: null },
{ id: 'o2', datetime: '2010-10-10T00:00:00.000+14:00' },
{ id: 'o3', datetime: null },
{ id: 'o4', datetime: null },
],
})

add_test({
title: 'datetime highBoundary',
Expand All @@ -108,20 +119,96 @@ describe('boundary functions', () => {
{
column: [
{ name: 'id', path: 'id' },
{
name: 'datetime',
path: 'value.ofType(DateTime).highBoundary()'
}
]
}
]
{ name: 'datetime', path: 'value.ofType(dateTime).highBoundary()' },
],
},
],
},
expect: [
{ id: 'o1', decimal: null },
{ id: 'o2', decimal: '2010-10-10T23:59:59.999-12:00' },
{ id: 'o3', decimal: null },
]
});
{ id: 'o1', datetime: null },
{ id: 'o2', datetime: '2010-10-10T23:59:59.999-12:00' },
{ id: 'o3', datetime: null },
{ id: 'o4', datetime: null },
],
})

add_test({
title: 'date lowBoundary',
view: {
resource: 'Patient',
status: 'active',
select: [
{
column: [
{ name: 'id', path: 'id' },
{ name: 'date', path: 'birthDate.lowBoundary()' },
],
},
],
},
expect: [{ id: 'p1', date: '1970-06-01' }],
})

add_test({
title: 'date highBoundary',
view: {
resource: 'Patient',
status: 'active',
select: [
{
column: [
{ name: 'id', path: 'id' },
{ name: 'date', path: 'birthDate.highBoundary()' },
],
},
],
},
expect: [{ id: 'p1', date: '1970-06-30' }],
})

add_test({
title: 'time lowBoundary',
view: {
resource: 'Observation',
status: 'active',
select: [
{
column: [
{ name: 'id', path: 'id' },
{ name: 'time', path: 'value.ofType(time).lowBoundary()' },
],
},
],
},
expect: [
{ id: 'o1', time: null },
{ id: 'o2', time: null },
{ id: 'o3', time: null },
{ id: 'o4', time: '12:34:00.000' },
],
})

add_test({
title: 'time highBoundary',
view: {
resource: 'Observation',
status: 'active',
select: [
{
column: [
{ name: 'id', path: 'id' },
{ name: 'time', path: 'value.ofType(time).highBoundary()' },
],
},
],
},
expect: [
{ id: 'o1', time: null },
{ id: 'o2', time: null },
{ id: 'o3', time: null },
{ id: 'o4', time: '12:34:59.999' },
],
})

end_case();
});
end_case()
})

0 comments on commit d009569

Please sign in to comment.