@@ -50,6 +50,7 @@ describe("HCAProjectComponent", () => {
5050 testConfig . getPortalURL . and . returnValue ( "https://test.com" ) ;
5151
5252 // Class names
53+ const CLASSNAME_BREAK = "break" ;
5354 const CLASSNAME_CITATION = ".citation" ;
5455 const CLASSNAME_CITATION_URL = ".citation .url" ;
5556 const CLASSNAME_PROJECT_DETAILS_LHS = ".project-details .lhs" ;
@@ -190,6 +191,28 @@ describe("HCAProjectComponent", () => {
190191 expect ( projectUrl ) . toEqual ( TEST_VALUE_CITATION_URL ) ;
191192 } ) ;
192193
194+ /**
195+ * Confirm is short name sentence returns true when project label is sentence case.
196+ */
197+ it ( "should is short name sentence returns true when project label is sentence case" , ( ) => {
198+
199+ const shortNameSentence = component . isShortNameSentence ( PROJECT_DETAIL_SPECIFIC_VALUES . projectShortname ) ;
200+
201+ // Confirm true is returned
202+ expect ( shortNameSentence ) . toEqual ( true ) ;
203+ } ) ;
204+
205+ /**
206+ * Confirm is short name sentence returns false when project label is not sentence case.
207+ */
208+ it ( "should is short name sentence returns false when project label is not sentence case" , ( ) => {
209+
210+ const shortNameSentence = component . isShortNameSentence ( PROJECT_DETAIL_SINGLE_VALUES . projectShortname ) ;
211+
212+ // Confirm false is returned
213+ expect ( shortNameSentence ) . toEqual ( false ) ;
214+ } ) ;
215+
193216 /**
194217 * Confirm "Citation" is displayed.
195218 */
@@ -268,6 +291,67 @@ describe("HCAProjectComponent", () => {
268291 expect ( getComponentInputPropertyValue ( copyToClipboard , COMPONENT_INPUT_PROPERTY_COPY_TO_CLIPBOARD_LINK ) ) . toEqual ( TEST_VALUE_CITATION_URL ) ;
269292 } ) ;
270293
294+ /**
295+ * Confirm "Project Label" is displayed.
296+ */
297+ it ( `should display "Project Label"` , ( ) => {
298+
299+ testStore . pipe
300+ . and . returnValues (
301+ of ( PROJECT_DETAIL_SINGLE_VALUES ) , // selected project detail
302+ of ( PROJECT_MATRIX_URLS_SINGLE_SPECIES ) , // project matrix URLs
303+ of ( [ ] ) , // project ids
304+ of ( [ ] ) // integrations
305+ ) ;
306+
307+ fixture . detectChanges ( ) ;
308+
309+ // Confirm "Project Label" is displayed
310+ expect ( isProjectDetailLabelDisplayed ( PROJECT_LABEL_PROJECT_SHORTNAME , CLASSNAME_PROJECT_DETAILS_LHS ) ) . toEqual ( true ) ;
311+ } ) ;
312+
313+ /**
314+ * Confirm class "break" is not displayed when "projectShortname" is sentence case.
315+ */
316+ it ( `should not display class "break" when "projectShortname" is sentence case` , ( ) => {
317+
318+ testStore . pipe
319+ . and . returnValues (
320+ of ( PROJECT_DETAIL_SPECIFIC_VALUES ) , // selected project detail
321+ of ( PROJECT_MATRIX_URLS_SINGLE_SPECIES ) , // project matrix URLs
322+ of ( [ ] ) , // project ids
323+ of ( [ ] ) // integrations
324+ ) ;
325+
326+ fixture . detectChanges ( ) ;
327+
328+ const projectDetailClasses = getProjectDetailClasses ( PROJECT_LABEL_PROJECT_SHORTNAME ) ;
329+
330+ // Confirm class is not displayed
331+ expect ( projectDetailClasses [ CLASSNAME_BREAK ] ) . toEqual ( false ) ;
332+ } ) ;
333+
334+ /**
335+ * Confirm class "break" is displayed when "projectShortname" is not sentence case.
336+ */
337+ it ( `should display class "break" when "projectShortname" is not sentence case` , ( ) => {
338+
339+ testStore . pipe
340+ . and . returnValues (
341+ of ( PROJECT_DETAIL_SINGLE_VALUES ) , // selected project detail
342+ of ( PROJECT_MATRIX_URLS_SINGLE_SPECIES ) , // project matrix URLs
343+ of ( [ ] ) , // project ids
344+ of ( [ ] ) // integrations
345+ ) ;
346+
347+ fixture . detectChanges ( ) ;
348+
349+ const projectDetailClasses = getProjectDetailClasses ( PROJECT_LABEL_PROJECT_SHORTNAME ) ;
350+
351+ // Confirm class is displayed
352+ expect ( projectDetailClasses [ CLASSNAME_BREAK ] ) . toEqual ( true ) ;
353+ } ) ;
354+
271355 /**
272356 * Confirm "Sample Type" is displayed.
273357 */
@@ -660,12 +744,12 @@ describe("HCAProjectComponent", () => {
660744 }
661745
662746 /**
663- * Returns the project detail value for the specified project detail.
747+ * Returns the project detail for the specified project detail label .
664748 *
665749 * @param {string } projectDetailLabel
666- * @returns {any }
750+ * @returns {DebugElement }
667751 */
668- function getProjectDetailValue ( projectDetailLabel : string ) : any {
752+ function getProjectDetail ( projectDetailLabel : string ) : DebugElement {
669753
670754 const projectDetailValueEls = fixture . debugElement . queryAll ( By . css ( CLASSNAME_PROJECT_DETAILS_RHS ) ) ;
671755
@@ -676,7 +760,43 @@ describe("HCAProjectComponent", () => {
676760
677761 const projectDetailIndex = PROJECT_DETAIL_DISPLAY_ORDER . indexOf ( projectDetailLabel ) ;
678762
679- return projectDetailValueEls [ projectDetailIndex ] . nativeElement . innerText ;
763+ return projectDetailValueEls [ projectDetailIndex ] ;
764+ }
765+
766+ /**
767+ * Returns the project detail classes for the specified project detail.
768+ *
769+ * @param {string } projectDetailLabel
770+ * @returns {Object }
771+ */
772+ function getProjectDetailClasses ( projectDetailLabel : string ) : Object {
773+
774+ const projectDetail = getProjectDetail ( projectDetailLabel ) ;
775+
776+ if ( ! projectDetail ) {
777+
778+ return ;
779+ }
780+
781+ return projectDetail . classes ;
782+ }
783+
784+ /**
785+ * Returns the project detail value for the specified project detail.
786+ *
787+ * @param {string } projectDetailLabel
788+ * @returns {any }
789+ */
790+ function getProjectDetailValue ( projectDetailLabel : string ) : any {
791+
792+ const projectDetail = getProjectDetail ( projectDetailLabel ) ;
793+
794+ if ( ! projectDetail ) {
795+
796+ return ;
797+ }
798+
799+ return projectDetail . nativeElement . innerText ;
680800 }
681801
682802
0 commit comments