Added additional tests for LevelledTopologicalSorter

This commit is contained in:
sanex3339
2019-12-30 20:53:05 +03:00
parent f8044a7248
commit d3bfe4c5b7
@@ -53,7 +53,7 @@ describe('EscapeSequenceEncoder', () => {
});
});
describe('Variant #1: Base sort with grouping', () => {
describe('Variant #2: Base sort with grouping', () => {
const expectedSortedItems: string[][] = [
['C', 'D', 'F'],
['A', 'E'],
@@ -71,5 +71,53 @@ describe('EscapeSequenceEncoder', () => {
});
});
});
describe('Sort without relations', () => {
beforeEach(() => {
levelledTopologicalSorter.add('A');
levelledTopologicalSorter.add('B');
levelledTopologicalSorter.add('C');
levelledTopologicalSorter.add('D');
levelledTopologicalSorter.add('E');
levelledTopologicalSorter.add('F');
});
describe('Variant #1: Should sort items without relations', () => {
const expectedSortedItems: string[] = [
'A',
'B',
'C',
'D',
'E',
'F'
];
let sortedItems: string[];
beforeEach(() => {
sortedItems = levelledTopologicalSorter.sort();
});
it('should topologically linear sort items', () => {
assert.deepEqual(sortedItems, expectedSortedItems);
});
});
describe('Variant #2: Should sort items without relations with grouping', () => {
const expectedSortedItems: string[][] = [
['A', 'B', 'C', 'D', 'E', 'F']
];
let sortedItems: string[][];
beforeEach(() => {
sortedItems = levelledTopologicalSorter.sortByGroups();
});
it('should topologically linear sort items', () => {
assert.deepEqual(sortedItems, expectedSortedItems);
});
});
});
});
});