mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
Added base tests for LevelledTopologicalSorter
This commit is contained in:
+1
-1
@@ -6,7 +6,7 @@ export interface ILevelledTopologicalSorter <TValue extends string = string> {
|
||||
*/
|
||||
add (
|
||||
precedent: TValue,
|
||||
consequent: TValue | null
|
||||
consequent?: TValue | null
|
||||
): this;
|
||||
|
||||
/**
|
||||
|
||||
@@ -34,6 +34,7 @@ import './unit-tests/storages/MapStorage.spec';
|
||||
import './unit-tests/utils/ArrayUtils.spec';
|
||||
import './unit-tests/utils/CryptUtils.spec';
|
||||
import './unit-tests/utils/EscapeSequenceEncoder.spec';
|
||||
import './unit-tests/utils/LevelledTopologicalSorter.spec';
|
||||
import './unit-tests/utils/NumberUtils.spec';
|
||||
import './unit-tests/utils/Utils.spec';
|
||||
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
import 'reflect-metadata';
|
||||
|
||||
import { assert } from 'chai';
|
||||
|
||||
import { InversifyContainerFacade } from '../../../src/container/InversifyContainerFacade';
|
||||
import { ServiceIdentifiers } from '../../../src/container/ServiceIdentifiers';
|
||||
|
||||
import { IInversifyContainerFacade } from '../../../src/interfaces/container/IInversifyContainerFacade';
|
||||
import { ILevelledTopologicalSorter } from '../../../src/interfaces/utils/ILevelledTopologicalSorter';
|
||||
|
||||
|
||||
describe('EscapeSequenceEncoder', () => {
|
||||
describe('encode', () => {
|
||||
let levelledTopologicalSorter: ILevelledTopologicalSorter;
|
||||
|
||||
beforeEach(() => {
|
||||
const inversifyContainerFacade: IInversifyContainerFacade = new InversifyContainerFacade();
|
||||
|
||||
inversifyContainerFacade.load('', '', {});
|
||||
levelledTopologicalSorter = inversifyContainerFacade
|
||||
.get<ILevelledTopologicalSorter>(ServiceIdentifiers.ILevelledTopologicalSorter);
|
||||
});
|
||||
|
||||
describe('Base sort', () => {
|
||||
beforeEach(() => {
|
||||
levelledTopologicalSorter.add('A', 'B');
|
||||
levelledTopologicalSorter.add('B');
|
||||
levelledTopologicalSorter.add('C', 'B');
|
||||
levelledTopologicalSorter.add('D');
|
||||
levelledTopologicalSorter.add('E');
|
||||
levelledTopologicalSorter.add('F', 'A');
|
||||
levelledTopologicalSorter.add('F', 'E');
|
||||
});
|
||||
|
||||
describe('Variant #1: Base linear sort', () => {
|
||||
const expectedSortedItems: string[] = [
|
||||
'F',
|
||||
'A',
|
||||
'C',
|
||||
'B',
|
||||
'D',
|
||||
'E',
|
||||
];
|
||||
|
||||
let sortedItems: string[];
|
||||
|
||||
beforeEach(() => {
|
||||
sortedItems = levelledTopologicalSorter.sort();
|
||||
});
|
||||
|
||||
it('should topologically linear sort items', () => {
|
||||
assert.deepEqual(sortedItems, expectedSortedItems);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Variant #1: Base sort with grouping', () => {
|
||||
const expectedSortedItems: string[][] = [
|
||||
['C', 'D', 'F'],
|
||||
['A', 'E'],
|
||||
['B']
|
||||
];
|
||||
|
||||
let sortedItems: string[][];
|
||||
|
||||
beforeEach(() => {
|
||||
sortedItems = levelledTopologicalSorter.sortByGroups();
|
||||
});
|
||||
|
||||
it('should topologically linear sort items', () => {
|
||||
assert.deepEqual(sortedItems, expectedSortedItems);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user