Browse Source

Added additional tests for LevelledTopologicalSorter

sanex3339 5 years ago
parent
commit
d3bfe4c5b7
1 changed files with 49 additions and 1 deletions
  1. 49 1
      test/unit-tests/utils/LevelledTopologicalSorter.spec.ts

+ 49 - 1
test/unit-tests/utils/LevelledTopologicalSorter.spec.ts

@@ -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);
+                });
+            });
+        });
     });
 });