@@ -9,8 +9,9 @@ import { DomainDetails, DomainPanelStatus } from '../models';
99
1010import { getTestAPIWrapper } from '../../../APIWrapper' ;
1111
12- import { SampleTypePropertiesPanel } from './SampleTypePropertiesPanel' ;
12+ import { getValidUnitKinds , SampleTypePropertiesPanel , UnitKinds } from './SampleTypePropertiesPanel' ;
1313import { SampleTypeModel } from './models' ;
14+ import { UNITS_KIND } from '../../../util/measurement' ;
1415
1516describe ( 'SampleTypePropertiesPanel' , ( ) => {
1617 const BASE_PROPS = {
@@ -114,15 +115,15 @@ describe('SampleTypePropertiesPanel', () => {
114115 container = renderWithAppContext (
115116 < SampleTypePropertiesPanel
116117 { ...BASE_PROPS }
118+ dataClassAliasCaption = "Source"
119+ dataClassParentageLabel = "source"
120+ dataClassTypeCaption = "source type"
121+ includeDataClasses
117122 model = { sampleTypeModel }
118123 parentOptions = { [ { schema : 'exp.data' } ] }
119- includeDataClasses
120- useSeparateDataClassesAliasMenu
121124 sampleAliasCaption = "Parent"
122125 sampleTypeCaption = "sample type"
123- dataClassAliasCaption = "Source"
124- dataClassTypeCaption = "source type"
125- dataClassParentageLabel = "source"
126+ useSeparateDataClassesAliasMenu
126127 />
127128 ) ;
128129 } ) ;
@@ -154,7 +155,6 @@ describe('SampleTypePropertiesPanel', () => {
154155 metricUnitProps = { {
155156 includeMetricUnitProperty : true ,
156157 metricUnitLabel : 'Display Units' ,
157- metricUnitRequired : true ,
158158 metricUnitHelpMsg : 'Sample storage volume will be displayed using the selected metric unit.' ,
159159 metricUnitOptions : [
160160 { id : 'mL' , label : 'ml' } ,
@@ -180,9 +180,9 @@ describe('SampleTypePropertiesPanel', () => {
180180 renderWithAppContext (
181181 < SampleTypePropertiesPanel
182182 { ...BASE_PROPS }
183- showLinkToStudy
184183 appPropertiesOnly = { false }
185184 model = { sampleTypeModelWithTimepoint }
185+ showLinkToStudy
186186 />
187187 ) ;
188188 } ) ;
@@ -201,9 +201,9 @@ describe('SampleTypePropertiesPanel', () => {
201201 renderWithAppContext (
202202 < SampleTypePropertiesPanel
203203 { ...BASE_PROPS }
204- showLinkToStudy = { false }
205204 appPropertiesOnly = { false }
206205 model = { sampleTypeModelWithTimepoint }
206+ showLinkToStudy = { false }
207207 />
208208 ) ;
209209 } ) ;
@@ -255,11 +255,11 @@ describe('SampleTypePropertiesPanel', () => {
255255 renderWithAppContext (
256256 < SampleTypePropertiesPanel
257257 { ...BASE_PROPS }
258- model = { SampleTypeModel . create ( data ) }
259- appPropertiesOnly = { false }
260258 aliquotNamePatternProps = { {
261259 showAliquotNameExpression : true ,
262260 } }
261+ appPropertiesOnly = { false }
262+ model = { SampleTypeModel . create ( data ) }
263263 namePreviews = { [ null , 'S-parentSample-1' ] }
264264 />
265265 ) ;
@@ -271,3 +271,30 @@ describe('SampleTypePropertiesPanel', () => {
271271 expect ( aliquotField . textContent ) . toEqual ( 'Aliquot Naming Pattern' ) ;
272272 } ) ;
273273} ) ;
274+
275+ describe ( 'getValidUnitKinds' , ( ) => {
276+ test ( 'returns all unit kinds when lockUnitKind and metricUnit are undefined' , ( ) => {
277+ const result = getValidUnitKinds ( ) ;
278+ expect ( result ) . toEqual ( Object . values ( UnitKinds ) ) ;
279+ } ) ;
280+
281+ test ( 'returns all unit kinds when lockUnitKind is false' , ( ) => {
282+ const result = getValidUnitKinds ( false , 'mL' ) ;
283+ expect ( result ) . toEqual ( Object . values ( UnitKinds ) ) ;
284+ } ) ;
285+
286+ test ( 'returns NONE and the unit kind matching the metricUnit when lockUnitKind is true' , ( ) => {
287+ const result = getValidUnitKinds ( true , 'mL' ) ;
288+ expect ( result ) . toEqual ( [ UnitKinds [ UNITS_KIND . NONE ] , UnitKinds [ UNITS_KIND . VOLUME ] ] ) ;
289+ } ) ;
290+
291+ test ( 'returns only NONE when lockUnitKind is true and metricUnit is invalid' , ( ) => {
292+ const result = getValidUnitKinds ( true , 'invalidUnit' ) ;
293+ expect ( result ) . toEqual ( [ UnitKinds [ UNITS_KIND . NONE ] ] ) ;
294+ } ) ;
295+
296+ test ( 'returns only all when lockUnitKind is true and metricUnit is undefined' , ( ) => {
297+ const result = getValidUnitKinds ( true ) ;
298+ expect ( result ) . toEqual ( Object . values ( UnitKinds ) ) ;
299+ } ) ;
300+ } ) ;
0 commit comments