102286a209
- (feat) add 'key as default value' post processor (closes #109) - (chore) move clean functionality to a post processor - (chore) move sort functionality to a post processor - (refactor) get rid of leading underscore on protected properties/methods
34 lines
938 B
TypeScript
34 lines
938 B
TypeScript
import { expect } from 'chai';
|
|
|
|
import { PostProcessorInterface } from '../../src/post-processors/post-processor.interface';
|
|
import { SortByKeyPostProcessor } from '../../src/post-processors/sort-by-key.post-processor';
|
|
import { TranslationCollection } from '../../src/utils/translation.collection';
|
|
|
|
describe('SortByKeyPostProcessor', () => {
|
|
|
|
let processor: PostProcessorInterface;
|
|
|
|
beforeEach(() => {
|
|
processor = new SortByKeyPostProcessor();
|
|
});
|
|
|
|
it('should sort keys alphanumerically', () => {
|
|
const collection = new TranslationCollection({
|
|
'z': 'last value',
|
|
'a': 'a value',
|
|
'9': 'a numeric key',
|
|
'b': 'another value'
|
|
});
|
|
const extracted = new TranslationCollection();
|
|
const existing = new TranslationCollection();
|
|
|
|
expect(processor.process(collection, extracted, existing).values).to.deep.equal({
|
|
'9': 'a numeric key',
|
|
'a': 'a value',
|
|
'b': 'another value',
|
|
'z': 'last value'
|
|
});
|
|
});
|
|
|
|
});
|