@@ -24,6 +24,16 @@ describe("AnalysisProtocolPipelineLinkerComponent", () => {
2424 // Create response for testConfig.getPortalUrl()
2525 testConfig . getPortalURL . and . returnValue ( "https://test.com" ) ;
2626
27+ // Local values
28+ const LOCAL_VALUE_PIPELINE_LINKS_BY_ANALYSIS_PROTOCOL_KEY = {
29+ "smartseq2" : "/pipelines/smart-seq2-workflow" ,
30+ "optimus" : "/pipelines/optimus-workflow"
31+ } ;
32+
33+ // Index values
34+ const INDEX_OF_PIPELINE_LINKS_BY_ANALYSIS_PROTOCOL_KEY_OPTIMUS = 1 ;
35+ const INDEX_OF_PIPELINE_LINKS_BY_ANALYSIS_PROTOCOL_KEY_SMARTSEQ2 = 0 ;
36+
2737 // Template values
2838 const TEMPLATE_VALUE_DATA_PORTAL_LINK_SMARTSEQ2 = "/pipelines/smart-seq2-workflow" ;
2939 const TEMPLATE_VALUE_DATA_PORTAL_LINK_OPTIMUS = "/pipelines/optimus-workflow" ;
@@ -67,114 +77,145 @@ describe("AnalysisProtocolPipelineLinkerComponent", () => {
6777 } ) ;
6878
6979 /**
70- * Confirm get analysis protocols returns a concatenated string array when multiple workflow values .
80+ * Confirm get pipeline link returns corresponding data portal optimus link when analysis protocol includes "optimus" .
7181 */
72- it ( " should get analysis protocols returns a concatenated string array when multiple workflow values" , ( ) => {
82+ it ( ` should get pipeline link returns corresponding data portal optimus link when analysis protocol includes "optimus"` , ( ) => {
7383
74- component . workflow = INPUT_VALUE_WORKFLOW_MULTIPLE_MIXED_VALUES ;
75- fixture . detectChanges ( ) ;
84+ // Confirm link is for data portal optimus
85+ const pipelineLink = component . getPipelineLink ( TEST_VALUE_OPTIMUS ) ;
86+ expect ( pipelineLink ) . toEqual ( `${ testConfig . getPortalURL ( ) } ${ TEMPLATE_VALUE_DATA_PORTAL_LINK_OPTIMUS } ` ) ;
87+ } ) ;
7688
77- // Confirm get analysis protocols returns a concatenated string array
78- const getAnalysisProtocols = component . getAnalysisProtocols ( ) ;
79- expect ( getAnalysisProtocols ) . toEqual ( TEST_VALUE_ANALYSIS_PROTOCOLS_MULTIPLE_MIXED_VALUES ) ;
89+ /**
90+ * Confirm get pipeline link returns corresponding data portal smartseq2 link when analysis protocol includes "smartseq2".
91+ */
92+ it ( `should get pipeline link returns corresponding data portal smartseq2 link when analysis protocol includes "smartseq2"` , ( ) => {
93+
94+ // Confirm link is for data portal smartseq2
95+ const pipelineLink = component . getPipelineLink ( TEST_VALUE_SMARTSEQ2 ) ;
96+ expect ( pipelineLink ) . toEqual ( `${ testConfig . getPortalURL ( ) } ${ TEMPLATE_VALUE_DATA_PORTAL_LINK_SMARTSEQ2 } ` ) ;
8097 } ) ;
8198
8299 /**
83- * Confirm get analysis protocols returns a string array when single workflow values .
100+ * Confirm get pipeline link returns the root base path when there is no corresponding pipeline .
84101 */
85- it ( "should get analysis protocols returns a string array when single workflow values " , ( ) => {
102+ it ( "should get pipeline link returns the root base path when there is no corresponding pipeline " , ( ) => {
86103
87- component . workflow = INPUT_VALUE_WORKFLOW_SINGLE_OPTIMUS_VALUE ;
88- fixture . detectChanges ( ) ;
104+ // Confirm no link is returned
105+ const pipelineLink = component . getPipelineLink ( TEST_VALUE_CELL_RANGER ) ;
106+ expect ( pipelineLink ) . toEqual ( "/" ) ;
107+ } ) ;
89108
90- // Confirm get analysis protocols returns a string array
91- const getAnalysisProtocols = component . getAnalysisProtocols ( ) ;
92- expect ( getAnalysisProtocols ) . toEqual ( [ TEST_VALUE_OPTIMUS ] ) ;
109+ /**
110+ * Confirm is analysis protocol linked returns true when analysis protocol includes "optimus".
111+ */
112+ it ( `should is analysis protocol linked returns true when analysis protocol includes "optimus"` , ( ) => {
113+
114+ // Confirm true is returned
115+ const analysisProtocolLinked = component . isAnalysisProtocolLinked ( TEST_VALUE_OPTIMUS ) ;
116+ expect ( analysisProtocolLinked ) . toEqual ( true ) ;
93117 } ) ;
94118
95119 /**
96- * Confirm get analysis protocols returns an empty array when empty workflow values .
120+ * Confirm is analysis protocol linked returns true when analysis protocol includes "smartseq2" .
97121 */
98- it ( " should get analysis protocols returns an empty array when empty workflow values" , ( ) => {
122+ it ( ` should is analysis protocol linked returns true when analysis protocol includes "smartseq2"` , ( ) => {
99123
100- component . workflow = "" ;
101- fixture . detectChanges ( ) ;
124+ // Confirm true is returned
125+ const analysisProtocolLinked = component . isAnalysisProtocolLinked ( TEST_VALUE_SMARTSEQ2 ) ;
126+ expect ( analysisProtocolLinked ) . toEqual ( true ) ;
127+ } ) ;
102128
103- // Confirm get analysis protocols returns a concatenated string array
104- const getAnalysisProtocols = component . getAnalysisProtocols ( ) ;
105- expect ( getAnalysisProtocols ) . toEqual ( [ ] ) ;
129+ /**
130+ * Confirm is analysis protocol linked returns false when analysis protocol neither includes "smartseq2" nor "optimus".
131+ */
132+ it ( `should is analysis protocol linked returns true when analysis protocol neither includes "smartseq2" nor "optimus"` , ( ) => {
133+
134+ // Confirm true is returned
135+ const analysisProtocolLinked = component . isAnalysisProtocolLinked ( TEST_VALUE_CELL_RANGER ) ;
136+ expect ( analysisProtocolLinked ) . toEqual ( false ) ;
106137 } ) ;
138+
107139 /**
108- * Confirm get analysis protocols returns a string array when single workflow values.
140+ * Confirm list analysis protocols returns a concatenated string array when multiple workflow values.
109141 */
110- it ( "should get analysis protocols returns a string array when single workflow values" , ( ) => {
142+ it ( "should list analysis protocols returns a concatenated string array when multiple workflow values" , ( ) => {
111143
112- component . workflow = INPUT_VALUE_WORKFLOW_SINGLE_OPTIMUS_VALUE ;
144+ component . workflow = INPUT_VALUE_WORKFLOW_MULTIPLE_MIXED_VALUES ;
113145 fixture . detectChanges ( ) ;
114146
115- // Confirm get analysis protocols returns a string array
116- const getAnalysisProtocols = component . getAnalysisProtocols ( ) ;
117- expect ( getAnalysisProtocols ) . toEqual ( [ TEST_VALUE_OPTIMUS ] ) ;
147+ // Confirm get analysis protocols returns a concatenated string array
148+ const analysisProtocols = component . listAnalysisProtocols ( ) ;
149+ expect ( analysisProtocols ) . toEqual ( TEST_VALUE_ANALYSIS_PROTOCOLS_MULTIPLE_MIXED_VALUES ) ;
118150 } ) ;
119151
120152 /**
121- * Confirm get pipeline link returns corresponding data portal optimus link when analysis protocol includes "optimus" .
153+ * Confirm list analysis protocols returns a string array when single workflow values .
122154 */
123- it ( ` should get pipeline link returns corresponding data portal optimus link when analysis protocol includes "optimus"` , ( ) => {
155+ it ( " should list analysis protocols returns a string array when single workflow values" , ( ) => {
124156
125- // Confirm link is for data portal optimus
126- const getPipelineLink = component . getPipelineLink ( TEST_VALUE_OPTIMUS ) ;
127- expect ( getPipelineLink ) . toEqual ( testConfig . getPortalURL ( ) + TEMPLATE_VALUE_DATA_PORTAL_LINK_OPTIMUS ) ;
157+ component . workflow = INPUT_VALUE_WORKFLOW_SINGLE_OPTIMUS_VALUE ;
158+ fixture . detectChanges ( ) ;
159+
160+ // Confirm get analysis protocols returns a string array
161+ const analysisProtocols = component . listAnalysisProtocols ( ) ;
162+ expect ( analysisProtocols ) . toEqual ( [ TEST_VALUE_OPTIMUS ] ) ;
128163 } ) ;
129164
130165 /**
131- * Confirm get pipeline link returns corresponding data portal smartseq2 link when analysis protocol includes "smartseq2" .
166+ * Confirm list analysis protocols returns an empty array when empty workflow values .
132167 */
133- it ( ` should get pipeline link returns corresponding data portal smartseq2 link when analysis protocol includes "smartseq2"` , ( ) => {
168+ it ( " should list analysis protocols returns an empty array when empty workflow values" , ( ) => {
134169
135- // Confirm link is for data portal smartseq2
136- const getPipelineLink = component . getPipelineLink ( TEST_VALUE_SMARTSEQ2 ) ;
137- expect ( getPipelineLink ) . toEqual ( testConfig . getPortalURL ( ) + TEMPLATE_VALUE_DATA_PORTAL_LINK_SMARTSEQ2 ) ;
170+ component . workflow = "" ;
171+ fixture . detectChanges ( ) ;
172+
173+ // Confirm get analysis protocols returns a concatenated string array
174+ const analysisProtocols = component . listAnalysisProtocols ( ) ;
175+ expect ( analysisProtocols ) . toEqual ( [ ] ) ;
138176 } ) ;
139177
140178 /**
141- * Confirm get pipeline link returns the root base path when there is no corresponding pipeline .
179+ * Confirm list analysis protocols returns a string array when single workflow values .
142180 */
143- it ( "should get pipeline link returns the root base path when there is no corresponding pipeline " , ( ) => {
181+ it ( "should list analysis protocols returns a string array when single workflow values " , ( ) => {
144182
145- // Confirm no link is returned
146- const getPipelineLink = component . getPipelineLink ( TEST_VALUE_CELL_RANGER ) ;
147- expect ( getPipelineLink ) . toEqual ( "/" ) ;
183+ component . workflow = INPUT_VALUE_WORKFLOW_SINGLE_OPTIMUS_VALUE ;
184+ fixture . detectChanges ( ) ;
185+
186+ // Confirm get analysis protocols returns a string array
187+ const analysisProtocols = component . listAnalysisProtocols ( ) ;
188+ expect ( analysisProtocols ) . toEqual ( [ TEST_VALUE_OPTIMUS ] ) ;
148189 } ) ;
149190
150191 /**
151- * Confirm is analysis protocol linked returns true when analysis protocol includes "optimus".
192+ * Confirm find analysis protocol key returns "optimus" when analysis protocol includes "optimus".
152193 */
153- it ( `should is analysis protocol linked returns true when analysis protocol includes "optimus"` , ( ) => {
194+ it ( `should find analysis protocol key return "optimus" when analysis protocol includes "optimus"` , ( ) => {
154195
155- // Confirm true is returned
156- const isAnalysisProtocolLinked = component . isAnalysisProtocolLinked ( TEST_VALUE_OPTIMUS ) ;
157- expect ( isAnalysisProtocolLinked ) . toEqual ( true ) ;
196+ // Confirm key returned is "optimus"
197+ const analysisProtocolKey = component [ "findAnalysisProtocolKey" ] ( LOCAL_VALUE_PIPELINE_LINKS_BY_ANALYSIS_PROTOCOL_KEY , TEST_VALUE_OPTIMUS ) ;
198+ expect ( analysisProtocolKey ) . toEqual ( Object . keys ( LOCAL_VALUE_PIPELINE_LINKS_BY_ANALYSIS_PROTOCOL_KEY ) [ INDEX_OF_PIPELINE_LINKS_BY_ANALYSIS_PROTOCOL_KEY_OPTIMUS ] ) ;
158199 } ) ;
159200
160201 /**
161- * Confirm is analysis protocol linked returns true when analysis protocol includes "smartseq2".
202+ * Confirm find analysis protocol key returns "smartseq2" when analysis protocol includes "smartseq2".
162203 */
163- it ( `should is analysis protocol linked returns true when analysis protocol includes "smartseq2"` , ( ) => {
204+ it ( `should find analysis protocol key return "smartseq2" when analysis protocol includes "smartseq2"` , ( ) => {
164205
165- // Confirm true is returned
166- const isAnalysisProtocolLinked = component . isAnalysisProtocolLinked ( TEST_VALUE_SMARTSEQ2 ) ;
167- expect ( isAnalysisProtocolLinked ) . toEqual ( true ) ;
206+ // Confirm key returned is "smartseq2"
207+ const analysisProtocolKey = component [ "findAnalysisProtocolKey" ] ( LOCAL_VALUE_PIPELINE_LINKS_BY_ANALYSIS_PROTOCOL_KEY , TEST_VALUE_SMARTSEQ2 ) ;
208+ expect ( analysisProtocolKey ) . toEqual ( Object . keys ( LOCAL_VALUE_PIPELINE_LINKS_BY_ANALYSIS_PROTOCOL_KEY ) [ INDEX_OF_PIPELINE_LINKS_BY_ANALYSIS_PROTOCOL_KEY_SMARTSEQ2 ] ) ;
168209 } ) ;
169210
170211 /**
171- * Confirm is analysis protocol linked returns false when analysis protocol neither includes "smartseq2" nor "optimus".
212+ * Confirm find analysis protocol key returns undefined when analysis protocol is neither includes "smartseq2" nor "optimus".
172213 */
173- it ( `should is analysis protocol linked returns true when analysis protocol neither includes "smartseq2" nor "optimus"` , ( ) => {
214+ it ( `should find analysis protocol key return undefined when analysis protocol is neither includes "smartseq2" nor "optimus"` , ( ) => {
174215
175- // Confirm true is returned
176- const isAnalysisProtocolLinked = component . isAnalysisProtocolLinked ( TEST_VALUE_CELL_RANGER ) ;
177- expect ( isAnalysisProtocolLinked ) . toEqual ( false ) ;
216+ // Confirm key returned is undefined
217+ const analysisProtocolKey = component [ "findAnalysisProtocolKey" ] ( LOCAL_VALUE_PIPELINE_LINKS_BY_ANALYSIS_PROTOCOL_KEY , TEST_VALUE_CELL_RANGER ) ;
218+ expect ( analysisProtocolKey ) . toBeUndefined ( ) ;
178219 } ) ;
179220
180221 /**
@@ -206,30 +247,17 @@ describe("AnalysisProtocolPipelineLinkerComponent", () => {
206247 } ) ;
207248
208249 /**
209- * Confirm all linked analysis protocols are displayed, when multiple mixed workflow.
250+ * Confirm all analysis protocols are displayed, when multiple mixed workflow.
210251 */
211- it ( "should display all linked analysis protocols when multiple mixed workflow" , ( ) => {
252+ it ( "should display all analysis protocols when multiple mixed workflow" , ( ) => {
212253
213254 // Set up initial component state
214255 component . workflow = INPUT_VALUE_WORKFLOW_MULTIPLE_MIXED_VALUES ;
215256
216257 fixture . detectChanges ( ) ;
217258
218- // Confirm linked protocols are displayed
259+ // Confirm all protocols are displayed
219260 expect ( getAnalysisProtocolsDisplayed ( "a" ) . length ) . toEqual ( 2 ) ;
220- } ) ;
221-
222- /**
223- * Confirm all unlinked analysis protocols are displayed, when multiple mixed workflow.
224- */
225- it ( "should display all unlinked analysis protocols when multiple mixed workflow" , ( ) => {
226-
227- // Set up initial component state
228- component . workflow = INPUT_VALUE_WORKFLOW_MULTIPLE_MIXED_VALUES ;
229-
230- fixture . detectChanges ( ) ;
231-
232- // Confirm unlinked protocols are displayed
233261 expect ( getAnalysisProtocolsDisplayed ( "span" ) . length ) . toEqual ( 1 ) ;
234262 } ) ;
235263
@@ -261,7 +289,7 @@ describe("AnalysisProtocolPipelineLinkerComponent", () => {
261289 const analysisPortalDEs = getAnalysisProtocolsDisplayed ( "a" ) ;
262290
263291 // Confirm href link
264- expect ( getHrefValue ( analysisPortalDEs [ 0 ] ) ) . toEqual ( testConfig . getPortalURL ( ) + TEMPLATE_VALUE_DATA_PORTAL_LINK_OPTIMUS ) ;
292+ expect ( getHrefValue ( analysisPortalDEs [ 0 ] ) ) . toEqual ( ` ${ testConfig . getPortalURL ( ) } ${ TEMPLATE_VALUE_DATA_PORTAL_LINK_OPTIMUS } ` ) ;
265293 } ) ;
266294
267295 /**
@@ -277,7 +305,7 @@ describe("AnalysisProtocolPipelineLinkerComponent", () => {
277305 const analysisPortalDEs = getAnalysisProtocolsDisplayed ( "a" ) ;
278306
279307 // Confirm href link
280- expect ( getHrefValue ( analysisPortalDEs [ 0 ] ) ) . toEqual ( testConfig . getPortalURL ( ) + TEMPLATE_VALUE_DATA_PORTAL_LINK_SMARTSEQ2 ) ;
308+ expect ( getHrefValue ( analysisPortalDEs [ 0 ] ) ) . toEqual ( ` ${ testConfig . getPortalURL ( ) } ${ TEMPLATE_VALUE_DATA_PORTAL_LINK_SMARTSEQ2 } ` ) ;
281309 } ) ;
282310
283311 /**
0 commit comments