mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-4892] DocumentList - set appropriate column aria-sort state (#5079)
* set specific aria-sort state * return false when table has no sorting * move logic to component * aria sort method * tests
This commit is contained in:
committed by
Eugenio Romano
parent
30089f485f
commit
d5b4caa5ed
@@ -750,6 +750,38 @@ describe('DataTable', () => {
|
||||
|
||||
});
|
||||
|
||||
it('should indicate column that has sorting applied', () => {
|
||||
dataTable.data = new ObjectDataTableAdapter(
|
||||
[ { name: '1' }, { name: '2' } ],
|
||||
[
|
||||
new ObjectDataColumn({ key: 'name', sortable: true }),
|
||||
new ObjectDataColumn({ key: 'other', sortable: true })
|
||||
]
|
||||
);
|
||||
|
||||
const [col1, col2] = dataTable.getSortableColumns();
|
||||
|
||||
dataTable.onColumnHeaderClick(col2);
|
||||
|
||||
expect(dataTable.isColumnSortActive(col1)).toBe(false);
|
||||
expect(dataTable.isColumnSortActive(col2)).toBe(true);
|
||||
});
|
||||
|
||||
it('should return false for columns that have no sorting', () => {
|
||||
dataTable.data = new ObjectDataTableAdapter(
|
||||
[ { name: '1' }, { name: '2' } ],
|
||||
[
|
||||
new ObjectDataColumn({ key: 'name', sortable: false }),
|
||||
new ObjectDataColumn({ key: 'other', sortable: false })
|
||||
]
|
||||
);
|
||||
|
||||
const [col1, col2] = dataTable.getSortableColumns();
|
||||
|
||||
expect(dataTable.isColumnSortActive(col1)).toBe(false);
|
||||
expect(dataTable.isColumnSortActive(col2)).toBe(false);
|
||||
});
|
||||
|
||||
it('should invert "select all" status', () => {
|
||||
expect(dataTable.isSelectAllChecked).toBeFalsy();
|
||||
dataTable.onSelectAllClick(<MatCheckboxChange> { checked: true });
|
||||
@@ -1102,4 +1134,33 @@ describe('Accesibility', () => {
|
||||
expect(datatableBodyRowAttributes.getNamedItem('role').value).toEqual('row');
|
||||
expect(datatableBodyCellAttributes.getNamedItem('role').value).toEqual('gridcell');
|
||||
});
|
||||
|
||||
describe('aria-sort', () => {
|
||||
let column: DataColumn;
|
||||
|
||||
beforeEach(() => {
|
||||
column = new ObjectDataColumn({ key: 'key' });
|
||||
});
|
||||
|
||||
it('should return correct translation key when no sort is applied', () => {
|
||||
spyOn(dataTable, 'isColumnSortActive').and.returnValue(false);
|
||||
expect(dataTable.getAriaSort(column)).toBe('ADF-DATATABLE.ACCESSIBILITY.SORT_NONE');
|
||||
});
|
||||
|
||||
it('should return translation key when column sort is ascending', () => {
|
||||
const isColumnSortedAsc = true;
|
||||
spyOn(dataTable, 'isColumnSortActive').and.returnValue(true);
|
||||
spyOn(dataTable, 'isColumnSorted').and.returnValue(isColumnSortedAsc);
|
||||
|
||||
expect(dataTable.getAriaSort(column)).toBe('ADF-DATATABLE.ACCESSIBILITY.SORT_ASCENDING');
|
||||
});
|
||||
|
||||
it('should return translation key when column sort is descending', () => {
|
||||
const isColumnSortedAsc = false;
|
||||
spyOn(dataTable, 'isColumnSortActive').and.returnValue(true);
|
||||
spyOn(dataTable, 'isColumnSorted').and.returnValue(isColumnSortedAsc);
|
||||
|
||||
expect(dataTable.getAriaSort(column)).toBe('ADF-DATATABLE.ACCESSIBILITY.SORT_DESCENDING');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user