mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
Added additional tests for LevelledTopologicalSorter
This commit is contained in:
@@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user