Skip to content

Commit 5aa835e

Browse files
authored
[DT-1288][risk=no] Create commonly used select options from typed objects (#2806)
1 parent 5a8b93f commit 5aa835e

File tree

8 files changed

+382
-41
lines changed

8 files changed

+382
-41
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import {
2+
asIdAndDisplayText, getFormattedName,
3+
SelectOptionWithKeyNameAndAbbreviation
4+
} from '../../../src/components/forms/SelectOptionInterface';
5+
6+
describe('SelectOptions tests', () => {
7+
describe('getFormattedName tests',()=>{
8+
it('should render expected name when key, name are present ',()=>{
9+
const entry: SelectOptionWithKeyNameAndAbbreviation = {key: 'en', name: 'Entry'};
10+
expect(getFormattedName(entry)).to.be.equal('Entry');
11+
});
12+
it('should render expected name when key, name, and abbreviation are present ',()=>{
13+
const entry: SelectOptionWithKeyNameAndAbbreviation = {key: 'en', name: 'Entry', abbreviation:'EN'};
14+
expect(getFormattedName(entry)).to.be.equal('Entry (EN)');
15+
});
16+
});
17+
18+
describe('asIdAndDisplayText tests', ()=>{
19+
it('test single entry in list',()=>{
20+
const entry: SelectOptionWithKeyNameAndAbbreviation = {key: 'en', name: 'Entry', abbreviation:'EN'};
21+
const entryList = asIdAndDisplayText([entry]);
22+
expect(entryList.length).to.be.equal(1);
23+
expect(entryList[0].displayText).to.be.equal('Entry (EN)');
24+
});
25+
26+
it('test empty entry list',()=>{
27+
const entryList = asIdAndDisplayText([]);
28+
expect(entryList.length).to.be.equal(0);
29+
});
30+
});
31+
})

cypress/component/Forms/forms.spec.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,6 @@ describe('FormField - Tests', () => {
675675

676676
});
677677

678-
679678
it('allows multiple selection with string array', () => {
680679
cy.spy(props, 'onChange');
681680
props.selectOptions = ['Observational', 'Prospective', 'Other'];

package-lock.json

Lines changed: 40 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/forms/DataTypes.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import {SelectOptionWithKeyNameAndAbbreviation} from './SelectOptionInterface';
2+
3+
4+
export class DataTypes {
5+
static CITE: SelectOptionWithKeyNameAndAbbreviation = {
6+
key: 'CITE',
7+
name: 'CITE-seq'
8+
};
9+
static HYB: SelectOptionWithKeyNameAndAbbreviation = {
10+
key: 'HYB',
11+
name: 'Hybrid Capture'
12+
};
13+
static RNA: SelectOptionWithKeyNameAndAbbreviation = {
14+
key:'RNA',
15+
name: 'RNA-Seq'
16+
}
17+
static SCRNA: SelectOptionWithKeyNameAndAbbreviation = {
18+
key:'scRNA',
19+
name: 'scRNA-Seq'
20+
}
21+
static SPT: SelectOptionWithKeyNameAndAbbreviation = {
22+
key: 'SPT',
23+
name: 'Spatial Transcriptomics'
24+
}
25+
static SNRNA: SelectOptionWithKeyNameAndAbbreviation = {
26+
key: 'snRNA',
27+
name: 'snRNA-Seq'
28+
}
29+
static WGS: SelectOptionWithKeyNameAndAbbreviation = {
30+
key: 'WGS',
31+
abbreviation:'WGS',
32+
name: 'Whole Genome'
33+
}
34+
static WES: SelectOptionWithKeyNameAndAbbreviation = {
35+
key: 'WES',
36+
abbreviation: 'WES',
37+
name: 'Whole Exome'
38+
}
39+
40+
static VALUES:SelectOptionWithKeyNameAndAbbreviation[] = [DataTypes.CITE,
41+
DataTypes.HYB,
42+
DataTypes.RNA,
43+
DataTypes.SCRNA,
44+
DataTypes.SPT,
45+
DataTypes.SNRNA,
46+
DataTypes.WGS,
47+
DataTypes.WES]
48+
}

0 commit comments

Comments
 (0)