2019-06-12 00:06:47 +03:00
|
|
|
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({
|
2019-09-18 15:16:47 +03:00
|
|
|
z: 'last value',
|
|
|
|
a: 'a value',
|
2019-06-12 00:06:47 +03:00
|
|
|
'9': 'a numeric key',
|
2019-09-18 15:16:47 +03:00
|
|
|
b: 'another value'
|
2019-06-12 00:06:47 +03:00
|
|
|
});
|
|
|
|
const extracted = new TranslationCollection();
|
|
|
|
const existing = new TranslationCollection();
|
|
|
|
|
|
|
|
expect(processor.process(collection, extracted, existing).values).to.deep.equal({
|
|
|
|
'9': 'a numeric key',
|
2019-09-18 15:16:47 +03:00
|
|
|
a: 'a value',
|
|
|
|
b: 'another value',
|
|
|
|
z: 'last value'
|
2019-06-12 00:06:47 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|