Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion spa/src/app/files/hca-table-files/file-row-mapper.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ export const FILE_NULL_VALUES =
"format": null,
"name": null,
"sha256": null,
"size": null,
"size": 148,
"uuid": null,
"version": null,
"url": null
Expand Down
54 changes: 29 additions & 25 deletions spa/src/app/files/hca-table-files/hca-table-files.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,17 @@ describe("HCATableFilesComponent", () => {

const testStore = jasmine.createSpyObj("Store", ["pipe", "dispatch"]);

const ROW_INDEX_0 = 0;
const ROW_INDEX_1 = 1;
const ROW_INDEX_2 = 2;
const ROW_INDEX_3 = 3;
const INDEX_TABLE_ROW_SINGLE_VALUES = 0;
const INDEX_TABLE_ROW_MULTIPLE_VALUES_SINGLE_OBJECT = 1;
const INDEX_TABLE_ROW_EMPTY_ARRAY_VALUES = 3;
const INDEX_TABLE_ROW_NULL_VALUES = 4;

const PROTOCOL_ARRAY_INDEX_0 = 0;
const INDEX_PROTOCOL_OBJECT_0 = 0;

const WORKFLOW_COLUMN = "workflow";
const COLUMN_NAME_WORKFLOW = "workflow";

const HCA_CONTENT_UNSPECIFIED_DASH_COMPONENT = "hca-content-unspecified-dash";
const HCA_CONTENT_ELLIPSIS_COMPONENT = "hca-content-ellipsis";
const COMPONENT_NAME_HCA_CONTENT_UNSPECIFIED_DASH = "hca-content-unspecified-dash";
const COMPONENT_NAME_HCA_CONTENT_ELLIPSIS = "hca-content-ellipsis";

beforeEach(async(() => {

Expand Down Expand Up @@ -253,7 +253,7 @@ describe("HCATableFilesComponent", () => {

fixture.detectChanges();

const columnHeaderDE = findHeader(WORKFLOW_COLUMN);
const columnHeaderDE = findHeader(COLUMN_NAME_WORKFLOW);

// Confirm column "Analysis Protocol" is displayed
expect(columnHeaderDE.nativeElement.innerText).toEqual("Analysis Protocol");
Expand All @@ -276,8 +276,8 @@ describe("HCATableFilesComponent", () => {

fixture.detectChanges();

// Confirm first row in column "Analysis Protocol" displays component
expect(findColumnCellComponent(ROW_INDEX_0, WORKFLOW_COLUMN, HCA_CONTENT_UNSPECIFIED_DASH_COMPONENT)).not.toBe(null);
// Confirm row with empty array values in column "Analysis Protocol" displays component
expect(findColumnCellComponent(INDEX_TABLE_ROW_EMPTY_ARRAY_VALUES, COLUMN_NAME_WORKFLOW, COMPONENT_NAME_HCA_CONTENT_UNSPECIFIED_DASH)).not.toBe(null);
});

/**
Expand All @@ -297,8 +297,8 @@ describe("HCATableFilesComponent", () => {

fixture.detectChanges();

// Confirm second row in column "Analysis Protocol" displays component
expect(findColumnCellComponent(ROW_INDEX_1, WORKFLOW_COLUMN, HCA_CONTENT_UNSPECIFIED_DASH_COMPONENT)).not.toBe(null);
// Confirm row with null values in column "Analysis Protocol" displays component
expect(findColumnCellComponent(INDEX_TABLE_ROW_NULL_VALUES, COLUMN_NAME_WORKFLOW, COMPONENT_NAME_HCA_CONTENT_UNSPECIFIED_DASH)).not.toBe(null);
});

/**
Expand All @@ -318,8 +318,8 @@ describe("HCATableFilesComponent", () => {

fixture.detectChanges();

// Confirm first row in column "Analysis Protocol" does not display component
expect(findColumnCellComponent(ROW_INDEX_0, WORKFLOW_COLUMN, HCA_CONTENT_ELLIPSIS_COMPONENT)).toBe(null);
// Confirm row with empty values in column "Analysis Protocol" does not display component
expect(findColumnCellComponent(INDEX_TABLE_ROW_EMPTY_ARRAY_VALUES, COLUMN_NAME_WORKFLOW, COMPONENT_NAME_HCA_CONTENT_ELLIPSIS)).toBe(null);
});

/**
Expand All @@ -339,8 +339,8 @@ describe("HCATableFilesComponent", () => {

fixture.detectChanges();

// Confirm second row in column "Analysis Protocol" does not display component
expect(findColumnCellComponent(ROW_INDEX_1, WORKFLOW_COLUMN, HCA_CONTENT_ELLIPSIS_COMPONENT)).toBe(null);
// Confirm row with null values in column "Analysis Protocol" does not display component
expect(findColumnCellComponent(INDEX_TABLE_ROW_NULL_VALUES, COLUMN_NAME_WORKFLOW, COMPONENT_NAME_HCA_CONTENT_ELLIPSIS)).toBe(null);
});

/**
Expand All @@ -360,10 +360,10 @@ describe("HCATableFilesComponent", () => {

fixture.detectChanges();

const columnRowDE = findColumnCells(WORKFLOW_COLUMN)[ROW_INDEX_2];
const columnRowDE = findColumnCells(COLUMN_NAME_WORKFLOW)[INDEX_TABLE_ROW_SINGLE_VALUES];

// Confirm third row in column "Analysis Protocol" displays a single value
expect(columnRowDE.nativeElement.innerText).toEqual(FILES_TABLE_MODEL.data[ROW_INDEX_2].protocols[PROTOCOL_ARRAY_INDEX_0].workflow.join(", "));
// Confirm row with single values in column "Analysis Protocol" displays a single value
expect(columnRowDE.nativeElement.innerText).toEqual(FILES_TABLE_MODEL.data[INDEX_TABLE_ROW_SINGLE_VALUES].protocols[INDEX_PROTOCOL_OBJECT_0].workflow.join(", "));
});

/**
Expand All @@ -383,10 +383,10 @@ describe("HCATableFilesComponent", () => {

fixture.detectChanges();

const columnRowDE = findColumnCells(WORKFLOW_COLUMN)[ROW_INDEX_3];
const columnRowDE = findColumnCells(COLUMN_NAME_WORKFLOW)[INDEX_TABLE_ROW_MULTIPLE_VALUES_SINGLE_OBJECT];

// Confirm fourth row in column "Analysis Protocol" displays multiple string value
expect(columnRowDE.nativeElement.innerText).toEqual(FILES_TABLE_MODEL.data[ROW_INDEX_3].protocols[PROTOCOL_ARRAY_INDEX_0].workflow.join(", "));
// Confirm row with multiple string values in column "Analysis Protocol" displays multiple string value
expect(columnRowDE.nativeElement.innerText).toEqual(FILES_TABLE_MODEL.data[INDEX_TABLE_ROW_MULTIPLE_VALUES_SINGLE_OBJECT].protocols[INDEX_PROTOCOL_OBJECT_0].workflow.join(", "));
});

/**
Expand All @@ -406,8 +406,8 @@ describe("HCATableFilesComponent", () => {

fixture.detectChanges();

// Confirm third row in column "Analysis Protocol" does not display component
expect(findColumnCellComponent(ROW_INDEX_2, WORKFLOW_COLUMN, HCA_CONTENT_UNSPECIFIED_DASH_COMPONENT)).toBe(null);
// Confirm row with single values in column "Analysis Protocol" does not display component
expect(findColumnCellComponent(INDEX_TABLE_ROW_SINGLE_VALUES, COLUMN_NAME_WORKFLOW, COMPONENT_NAME_HCA_CONTENT_UNSPECIFIED_DASH)).toBe(null);
});

/**
Expand Down Expand Up @@ -435,6 +435,10 @@ describe("HCATableFilesComponent", () => {

const columnRowDE = findColumnCells(columnName)[rowIndex];

if ( !columnRowDE ) {
return null;
}

return columnRowDE.nativeElement.querySelector(componentName);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export class HCATableFilesComponent implements OnInit, AfterViewInit {
*/
public getFileDownloadClass(tableData: string): { [className: string]: boolean } {

if ( tableData.indexOf(" ") == -1 ) {
if ( tableData && tableData.indexOf(" ") == -1 ) {
return {
"file-download": true,
truncate: true
Expand Down
Loading