- (feat) add concept of post processors

- (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
This commit is contained in:
Kim Biesbjerg
2019-06-11 23:06:47 +02:00
parent ab29c9ab67
commit 102286a209
22 changed files with 342 additions and 171 deletions

View File

@@ -0,0 +1,36 @@
import { expect } from 'chai';
import { PostProcessorInterface } from '../../src/post-processors/post-processor.interface';
import { PurgeObsoleteKeysPostProcessor } from '../../src/post-processors/purge-obsolete-keys.post-processor';
import { TranslationCollection } from '../../src/utils/translation.collection';
describe('KeyAsDefaultValuePostProcessor', () => {
let processor: PostProcessorInterface;
beforeEach(() => {
processor = new PurgeObsoleteKeysPostProcessor();
});
it('should purge obsolete keys', () => {
const collection = new TranslationCollection({
'I am completely new': '',
'I already exist': '',
'I already exist but was not present in extract': ''
});
const extracted = new TranslationCollection({
'I am completely new': '',
'I already exist': ''
});
const existing = new TranslationCollection({
'I already exist': '',
'I already exist but was not present in extract': ''
});
expect(processor.process(collection, extracted, existing).values).to.deep.equal({
'I am completely new': '',
'I already exist': ''
});
});
});