diff --git a/src/cli/cli.ts b/src/cli/cli.ts index 0cd0b55..e07e065 100755 --- a/src/cli/cli.ts +++ b/src/cli/cli.ts @@ -35,7 +35,6 @@ export const cli = yargs if (!fs.existsSync(dir) || !fs.statSync(dir).isDirectory()) { throw new Error(`The path you supplied was not found: '${dir}'`); } - }); return true; }) @@ -100,12 +99,7 @@ const extractTask = new ExtractTask(cli.input, cli.output, { }); // Parsers -const parsers: ParserInterface[] = [ - new PipeParser(), - new DirectiveParser(), - new ServiceParser(), - new MarkerParser() -]; +const parsers: ParserInterface[] = [new PipeParser(), new DirectiveParser(), new ServiceParser(), new MarkerParser()]; extractTask.setParsers(parsers); // Post processors diff --git a/src/cli/tasks/extract.task.ts b/src/cli/tasks/extract.task.ts index 9783c52..a0ecf63 100644 --- a/src/cli/tasks/extract.task.ts +++ b/src/cli/tasks/extract.task.ts @@ -118,11 +118,7 @@ export class ExtractTask implements TaskInterface { /** * Run strings through configured post processors */ - protected process( - draft: TranslationCollection, - extracted: TranslationCollection, - existing: TranslationCollection - ): TranslationCollection { + protected process(draft: TranslationCollection, extracted: TranslationCollection, existing: TranslationCollection): TranslationCollection { this.postProcessors.forEach(postProcessor => { draft = postProcessor.process(draft, extracted, existing); }); diff --git a/src/compilers/compiler.factory.ts b/src/compilers/compiler.factory.ts index eb9870b..2cc9d68 100644 --- a/src/compilers/compiler.factory.ts +++ b/src/compilers/compiler.factory.ts @@ -4,14 +4,16 @@ import { NamespacedJsonCompiler } from '../compilers/namespaced-json.compiler'; import { PoCompiler } from '../compilers/po.compiler'; export class CompilerFactory { - public static create(format: string, options?: {}): CompilerInterface { switch (format) { - case 'pot': return new PoCompiler(options); - case 'json': return new JsonCompiler(options); - case 'namespaced-json': return new NamespacedJsonCompiler(options); - default: throw new Error(`Unknown format: ${format}`); + case 'pot': + return new PoCompiler(options); + case 'json': + return new JsonCompiler(options); + case 'namespaced-json': + return new NamespacedJsonCompiler(options); + default: + throw new Error(`Unknown format: ${format}`); } } - } diff --git a/src/compilers/compiler.interface.ts b/src/compilers/compiler.interface.ts index 83b0575..89753c9 100644 --- a/src/compilers/compiler.interface.ts +++ b/src/compilers/compiler.interface.ts @@ -1,11 +1,9 @@ import { TranslationCollection } from '../utils/translation.collection'; export interface CompilerInterface { - extension: string; compile(collection: TranslationCollection): string; parse(contents: string): TranslationCollection; - } diff --git a/src/compilers/json.compiler.ts b/src/compilers/json.compiler.ts index 08e72f1..994a12d 100644 --- a/src/compilers/json.compiler.ts +++ b/src/compilers/json.compiler.ts @@ -5,7 +5,6 @@ import { stripBOM } from '../utils/utils'; import { flatten } from 'flat'; export class JsonCompiler implements CompilerInterface { - public indentation: string = '\t'; public extension: string = 'json'; @@ -31,5 +30,4 @@ export class JsonCompiler implements CompilerInterface { protected isNamespacedJsonFormat(values: any): boolean { return Object.keys(values).some(key => typeof values[key] === 'object'); } - } diff --git a/src/compilers/namespaced-json.compiler.ts b/src/compilers/namespaced-json.compiler.ts index c0e341b..c4fa943 100644 --- a/src/compilers/namespaced-json.compiler.ts +++ b/src/compilers/namespaced-json.compiler.ts @@ -5,7 +5,6 @@ import { stripBOM } from '../utils/utils'; import { flatten, unflatten } from 'flat'; export class NamespacedJsonCompiler implements CompilerInterface { - public indentation: string = '\t'; public extension = 'json'; @@ -27,5 +26,4 @@ export class NamespacedJsonCompiler implements CompilerInterface { const values: {} = flatten(JSON.parse(stripBOM(contents))); return new TranslationCollection(values); } - } diff --git a/src/parsers/directive.parser.ts b/src/parsers/directive.parser.ts index 26e691b..8e1773f 100644 --- a/src/parsers/directive.parser.ts +++ b/src/parsers/directive.parser.ts @@ -5,7 +5,6 @@ import { isPathAngularComponent, extractComponentInlineTemplate } from '../utils import { parseTemplate, TmplAstNode, TmplAstElement, TmplAstTextAttribute } from '@angular/compiler'; export class DirectiveParser implements ParserInterface { - public extract(source: string, filePath: string): TranslationCollection | null { if (filePath && isPathAngularComponent(filePath)) { source = extractComponentInlineTemplate(source); @@ -42,13 +41,16 @@ export class DirectiveParser implements ParserInterface { return [node]; } - return node.children.reduce((result: TmplAstElement[], childNode: TmplAstNode) => { - if (this.isElement(childNode)) { - const children = this.findChildrenElements(childNode); - return result.concat(children); - } - return result; - }, [node]); + return node.children.reduce( + (result: TmplAstElement[], childNode: TmplAstNode) => { + if (this.isElement(childNode)) { + const children = this.findChildrenElements(childNode); + return result.concat(children); + } + return result; + }, + [node] + ); } protected parseTemplate(template: string, path: string): TmplAstNode[] { @@ -56,9 +58,7 @@ export class DirectiveParser implements ParserInterface { } protected isElement(node: any): node is TmplAstElement { - return node - && node.attributes !== undefined - && node.children !== undefined; + return node && node.attributes !== undefined && node.children !== undefined; } protected isTranslatable(node: TmplAstNode): boolean { @@ -70,7 +70,7 @@ export class DirectiveParser implements ParserInterface { protected getElementTranslateAttrValue(element: TmplAstElement): string { const attr: TmplAstTextAttribute = element.attributes.find(attribute => attribute.name === 'translate'); - return attr && attr.value || ''; + return (attr && attr.value) || ''; } protected getElementContents(element: TmplAstElement): string { @@ -79,5 +79,4 @@ export class DirectiveParser implements ParserInterface { const end = element.endSourceSpan.start.offset; return contents.substring(start, end).trim(); } - } diff --git a/src/parsers/marker.parser.ts b/src/parsers/marker.parser.ts index 8606aa6..967fb18 100644 --- a/src/parsers/marker.parser.ts +++ b/src/parsers/marker.parser.ts @@ -8,7 +8,6 @@ const MARKER_MODULE_NAME = '@biesbjerg/ngx-translate-extract-marker'; const MARKER_IMPORT_NAME = 'marker'; export class MarkerParser implements ParserInterface { - public extract(source: string, filePath: string): TranslationCollection | null { const sourceFile = tsquery.ast(source, filePath); @@ -30,5 +29,4 @@ export class MarkerParser implements ParserInterface { }); return collection; } - } diff --git a/src/parsers/parser.interface.ts b/src/parsers/parser.interface.ts index 71b2aa0..75c0357 100644 --- a/src/parsers/parser.interface.ts +++ b/src/parsers/parser.interface.ts @@ -1,7 +1,5 @@ import { TranslationCollection } from '../utils/translation.collection'; export interface ParserInterface { - extract(source: string, filePath: string): TranslationCollection | null; - } diff --git a/src/parsers/pipe.parser.ts b/src/parsers/pipe.parser.ts index a45572d..ce180d7 100644 --- a/src/parsers/pipe.parser.ts +++ b/src/parsers/pipe.parser.ts @@ -3,7 +3,6 @@ import { TranslationCollection } from '../utils/translation.collection'; import { isPathAngularComponent, extractComponentInlineTemplate } from '../utils/utils'; export class PipeParser implements ParserInterface { - public extract(source: string, filePath: string): TranslationCollection | null { if (filePath && isPathAngularComponent(filePath)) { source = extractComponentInlineTemplate(source); @@ -17,11 +16,10 @@ export class PipeParser implements ParserInterface { const regExp: RegExp = /(['"`])((?:(?!\1).|\\\1)+)\1\s*\|\s*translate/g; let matches: RegExpExecArray; - while (matches = regExp.exec(template)) { - collection = collection.add(matches[2].split('\\\'').join('\'')); + while ((matches = regExp.exec(template))) { + collection = collection.add(matches[2].split("\\'").join("'")); } return collection; } - } diff --git a/src/parsers/service.parser.ts b/src/parsers/service.parser.ts index 68fe64d..ba295a5 100644 --- a/src/parsers/service.parser.ts +++ b/src/parsers/service.parser.ts @@ -8,7 +8,6 @@ const TRANSLATE_SERVICE_TYPE_REFERENCE = 'TranslateService'; const TRANSLATE_SERVICE_METHOD_NAMES = ['get', 'instant', 'stream']; export class ServiceParser implements ParserInterface { - public extract(source: string, filePath: string): TranslationCollection | null { const sourceFile = tsquery.ast(source, filePath); @@ -37,5 +36,4 @@ export class ServiceParser implements ParserInterface { }); return collection; } - } diff --git a/src/post-processors/key-as-default-value.post-processor.ts b/src/post-processors/key-as-default-value.post-processor.ts index 2a8aece..54f1040 100644 --- a/src/post-processors/key-as-default-value.post-processor.ts +++ b/src/post-processors/key-as-default-value.post-processor.ts @@ -2,11 +2,9 @@ import { TranslationCollection } from '../utils/translation.collection'; import { PostProcessorInterface } from './post-processor.interface'; export class KeyAsDefaultValuePostProcessor implements PostProcessorInterface { - public name: string = 'KeyAsDefaultValue'; public process(draft: TranslationCollection, extracted: TranslationCollection, existing: TranslationCollection): TranslationCollection { - return draft.map((key, val) => val === '' ? key : val); + return draft.map((key, val) => (val === '' ? key : val)); } - } diff --git a/src/post-processors/null-as-default-value.post-processor.ts b/src/post-processors/null-as-default-value.post-processor.ts index f6bdde6..f2927e6 100644 --- a/src/post-processors/null-as-default-value.post-processor.ts +++ b/src/post-processors/null-as-default-value.post-processor.ts @@ -2,11 +2,9 @@ import { TranslationCollection } from '../utils/translation.collection'; import { PostProcessorInterface } from './post-processor.interface'; export class NullAsDefaultValuePostProcessor implements PostProcessorInterface { - public name: string = 'NullAsDefaultValue'; public process(draft: TranslationCollection, extracted: TranslationCollection, existing: TranslationCollection): TranslationCollection { - return draft.map((key, val) => existing.get(key) === undefined ? null : val); + return draft.map((key, val) => (existing.get(key) === undefined ? null : val)); } - } diff --git a/src/post-processors/post-processor.interface.ts b/src/post-processors/post-processor.interface.ts index 4b4f4bd..b725074 100644 --- a/src/post-processors/post-processor.interface.ts +++ b/src/post-processors/post-processor.interface.ts @@ -1,9 +1,7 @@ import { TranslationCollection } from '../utils/translation.collection'; export interface PostProcessorInterface { - name: string; process(draft: TranslationCollection, extracted: TranslationCollection, existing: TranslationCollection): TranslationCollection; - } diff --git a/src/post-processors/purge-obsolete-keys.post-processor.ts b/src/post-processors/purge-obsolete-keys.post-processor.ts index 063bc5c..559ece0 100644 --- a/src/post-processors/purge-obsolete-keys.post-processor.ts +++ b/src/post-processors/purge-obsolete-keys.post-processor.ts @@ -2,11 +2,9 @@ import { TranslationCollection } from '../utils/translation.collection'; import { PostProcessorInterface } from './post-processor.interface'; export class PurgeObsoleteKeysPostProcessor implements PostProcessorInterface { - public name: string = 'PurgeObsoleteKeys'; public process(draft: TranslationCollection, extracted: TranslationCollection, existing: TranslationCollection): TranslationCollection { return draft.intersect(extracted); } - } diff --git a/src/post-processors/sort-by-key.post-processor.ts b/src/post-processors/sort-by-key.post-processor.ts index cf78b70..df4f50a 100644 --- a/src/post-processors/sort-by-key.post-processor.ts +++ b/src/post-processors/sort-by-key.post-processor.ts @@ -2,11 +2,9 @@ import { TranslationCollection } from '../utils/translation.collection'; import { PostProcessorInterface } from './post-processor.interface'; export class SortByKeyPostProcessor implements PostProcessorInterface { - public name: string = 'SortByKey'; public process(draft: TranslationCollection, extracted: TranslationCollection, existing: TranslationCollection): TranslationCollection { return draft.sort(); } - } diff --git a/src/utils/utils.ts b/src/utils/utils.ts index bb0767e..5447119 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -2,7 +2,7 @@ * Assumes file is an Angular component if type is javascript/typescript */ export function isPathAngularComponent(path: string): boolean { - return (/\.ts|js$/i).test(path); + return /\.ts|js$/i.test(path); } /** diff --git a/tests/compilers/namespaced-json.compiler.spec.ts b/tests/compilers/namespaced-json.compiler.spec.ts index df7d68e..48a6155 100644 --- a/tests/compilers/namespaced-json.compiler.spec.ts +++ b/tests/compilers/namespaced-json.compiler.spec.ts @@ -4,7 +4,6 @@ import { TranslationCollection } from '../../src/utils/translation.collection'; import { NamespacedJsonCompiler } from '../../src/compilers/namespaced-json.compiler'; describe('NamespacedJsonCompiler', () => { - let compiler: NamespacedJsonCompiler; beforeEach(() => { @@ -23,7 +22,10 @@ describe('NamespacedJsonCompiler', () => { } `; const collection: TranslationCollection = compiler.parse(contents); - expect(collection.values).to.deep.equal({'NAMESPACE.KEY.FIRST_KEY': '', 'NAMESPACE.KEY.SECOND_KEY': 'VALUE' }); + expect(collection.values).to.deep.equal({ + 'NAMESPACE.KEY.FIRST_KEY': '', + 'NAMESPACE.KEY.SECOND_KEY': 'VALUE' + }); }); it('should unflatten keys on compile', () => { @@ -59,11 +61,10 @@ describe('NamespacedJsonCompiler', () => { it('should not reorder keys when compiled', () => { const collection = new TranslationCollection({ - 'BROWSE': '', - 'LOGIN': '' + BROWSE: '', + LOGIN: '' }); const result: string = compiler.compile(collection); expect(result).to.equal('{\n\t"BROWSE": "",\n\t"LOGIN": ""\n}'); }); - }); diff --git a/tests/parsers/directive.parser.spec.ts b/tests/parsers/directive.parser.spec.ts index cc13705..fd34dde 100644 --- a/tests/parsers/directive.parser.spec.ts +++ b/tests/parsers/directive.parser.spec.ts @@ -3,7 +3,6 @@ import { expect } from 'chai'; import { DirectiveParser } from '../../src/parsers/directive.parser'; describe('DirectiveParser', () => { - const templateFilename: string = 'test.template.html'; const componentFilename: string = 'test.component.ts'; @@ -86,5 +85,4 @@ describe('DirectiveParser', () => { const keys = parser.extract(contents, componentFilename).keys(); expect(keys).to.deep.equal([]); }); - }); diff --git a/tests/parsers/marker.parser.spec.ts b/tests/parsers/marker.parser.spec.ts index a8a5669..8e34475 100644 --- a/tests/parsers/marker.parser.spec.ts +++ b/tests/parsers/marker.parser.spec.ts @@ -3,7 +3,6 @@ import { expect } from 'chai'; import { MarkerParser } from '../../src/parsers/marker.parser'; describe('MarkerParser', () => { - const componentFilename: string = 'test.component.ts'; let parser: MarkerParser; @@ -12,7 +11,6 @@ describe('MarkerParser', () => { parser = new MarkerParser(); }); - it('should extract strings using marker function', () => { const contents = ` import { marker } from '@biesbjerg/ngx-translate-extract-marker'; @@ -35,11 +33,6 @@ describe('MarkerParser', () => { _('Mix ' + \`of \` + 'different ' + \`types\`); `; const keys = parser.extract(contents, componentFilename).keys(); - expect(keys).to.deep.equal([ - 'Hello world', - 'This is a very very very very long line.', - 'Mix of different types' - ]); + expect(keys).to.deep.equal(['Hello world', 'This is a very very very very long line.', 'Mix of different types']); }); - }); diff --git a/tests/parsers/pipe.parser.spec.ts b/tests/parsers/pipe.parser.spec.ts index a6b9fae..64a6ce5 100644 --- a/tests/parsers/pipe.parser.spec.ts +++ b/tests/parsers/pipe.parser.spec.ts @@ -3,7 +3,6 @@ import { expect } from 'chai'; import { PipeParser } from '../../src/parsers/pipe.parser'; describe('PipeParser', () => { - const templateFilename: string = 'test.template.html'; let parser: PipeParser; @@ -118,5 +117,4 @@ describe('PipeParser', () => { const keys = parser.extract(contents, templateFilename).keys(); expect(keys).to.deep.equal(['message']); }); - }); diff --git a/tests/parsers/service.parser.spec.ts b/tests/parsers/service.parser.spec.ts index a3027d8..a116b9f 100644 --- a/tests/parsers/service.parser.spec.ts +++ b/tests/parsers/service.parser.spec.ts @@ -2,12 +2,9 @@ import { expect } from 'chai'; import { ServiceParser } from '../../src/parsers/service.parser'; -class TestServiceParser extends ServiceParser { - -} +class TestServiceParser extends ServiceParser {} describe('ServiceParser', () => { - const componentFilename: string = 'test.component.ts'; let parser: TestServiceParser; @@ -44,7 +41,7 @@ describe('ServiceParser', () => { expect(keys).to.deep.equal(['Fallback message']); }); - it('should extract strings in TranslateService\'s get() method', () => { + it("should extract strings in TranslateService's get() method", () => { const contents = ` @Component({ }) export class AppComponent { @@ -57,7 +54,7 @@ describe('ServiceParser', () => { expect(keys).to.deep.equal(['Hello World']); }); - it('should extract strings in TranslateService\'s instant() method', () => { + it("should extract strings in TranslateService's instant() method", () => { const contents = ` @Component({ }) export class AppComponent { @@ -70,7 +67,7 @@ describe('ServiceParser', () => { expect(keys).to.deep.equal(['Hello World']); }); - it('should extract strings in TranslateService\'s stream() method', () => { + it("should extract strings in TranslateService's stream() method", () => { const contents = ` @Component({ }) export class AppComponent { @@ -83,7 +80,7 @@ describe('ServiceParser', () => { expect(keys).to.deep.equal(['Hello World']); }); - it('should extract array of strings in TranslateService\'s get() method', () => { + it("should extract array of strings in TranslateService's get() method", () => { const contents = ` @Component({ }) export class AppComponent { @@ -96,7 +93,7 @@ describe('ServiceParser', () => { expect(keys).to.deep.equal(['Hello', 'World']); }); - it('should extract array of strings in TranslateService\'s instant() method', () => { + it("should extract array of strings in TranslateService's instant() method", () => { const contents = ` @Component({ }) export class AppComponent { @@ -109,7 +106,7 @@ describe('ServiceParser', () => { expect(key).to.deep.equal(['Hello', 'World']); }); - it('should extract array of strings in TranslateService\'s stream() method', () => { + it("should extract array of strings in TranslateService's stream() method", () => { const contents = ` @Component({ }) export class AppComponent { @@ -298,5 +295,4 @@ describe('ServiceParser', () => { const keys = parser.extract(contents, componentFilename).keys(); expect(keys).to.deep.equal(['Back']); }); - }); diff --git a/tests/parsers/utils.spec.ts b/tests/parsers/utils.spec.ts index 0cfe3c0..f0377d7 100644 --- a/tests/parsers/utils.spec.ts +++ b/tests/parsers/utils.spec.ts @@ -3,7 +3,6 @@ import { expect } from 'chai'; import { isPathAngularComponent, extractComponentInlineTemplate } from '../../src/utils/utils'; describe('Utils', () => { - it('should recognize js extension as angular component', () => { const result = isPathAngularComponent('test.js'); expect(result).to.equal(true); @@ -63,5 +62,4 @@ describe('Utils', () => { const template = extractComponentInlineTemplate(contents); expect(template).to.equal('\n\t\t\t\t\t

\n\t\t\t\t\t\tHello World\n\t\t\t\t\t

\n\t\t\t\t'); }); - }); diff --git a/tests/post-processors/key-as-default-value.post-processor.spec.ts b/tests/post-processors/key-as-default-value.post-processor.spec.ts index 7c8e8b4..5a3ca62 100644 --- a/tests/post-processors/key-as-default-value.post-processor.spec.ts +++ b/tests/post-processors/key-as-default-value.post-processor.spec.ts @@ -5,7 +5,6 @@ import { KeyAsDefaultValuePostProcessor } from '../../src/post-processors/key-as import { TranslationCollection } from '../../src/utils/translation.collection'; describe('KeyAsDefaultValuePostProcessor', () => { - let processor: PostProcessorInterface; beforeEach(() => { @@ -27,5 +26,4 @@ describe('KeyAsDefaultValuePostProcessor', () => { 'Use this key as value as well': 'Use this key as value as well' }); }); - }); diff --git a/tests/post-processors/null-as-default-value.post-processor.spec.ts b/tests/post-processors/null-as-default-value.post-processor.spec.ts index 9e741ae..b9e988f 100644 --- a/tests/post-processors/null-as-default-value.post-processor.spec.ts +++ b/tests/post-processors/null-as-default-value.post-processor.spec.ts @@ -5,7 +5,6 @@ import { NullAsDefaultValuePostProcessor } from '../../src/post-processors/null- import { TranslationCollection } from '../../src/utils/translation.collection'; describe('NullAsDefaultValuePostProcessor', () => { - let processor: PostProcessorInterface; beforeEach(() => { @@ -38,5 +37,4 @@ describe('NullAsDefaultValuePostProcessor', () => { 'String A': 'Streng A' }); }); - }); diff --git a/tests/post-processors/purge-obsolete-keys.post-processor.spec.ts b/tests/post-processors/purge-obsolete-keys.post-processor.spec.ts index cb17d5c..898b1b8 100644 --- a/tests/post-processors/purge-obsolete-keys.post-processor.spec.ts +++ b/tests/post-processors/purge-obsolete-keys.post-processor.spec.ts @@ -5,15 +5,14 @@ import { PurgeObsoleteKeysPostProcessor } from '../../src/post-processors/purge- import { TranslationCollection } from '../../src/utils/translation.collection'; describe('PurgeObsoleteKeysPostProcessor', () => { - - let processor: PostProcessorInterface; + let postProcessor: PostProcessorInterface; beforeEach(() => { - processor = new PurgeObsoleteKeysPostProcessor(); + postProcessor = new PurgeObsoleteKeysPostProcessor(); }); it('should purge obsolete keys', () => { - const collection = new TranslationCollection({ + const draft = new TranslationCollection({ 'I am completely new': '', 'I already exist': '', 'I already exist but was not present in extract': '' @@ -27,10 +26,9 @@ describe('PurgeObsoleteKeysPostProcessor', () => { 'I already exist but was not present in extract': '' }); - expect(processor.process(collection, extracted, existing).values).to.deep.equal({ + expect(postProcessor.process(draft, extracted, existing).values).to.deep.equal({ 'I am completely new': '', 'I already exist': '' }); }); - }); diff --git a/tests/post-processors/sort-by-key.post-processor.spec.ts b/tests/post-processors/sort-by-key.post-processor.spec.ts index 7be15c2..b1a33ea 100644 --- a/tests/post-processors/sort-by-key.post-processor.spec.ts +++ b/tests/post-processors/sort-by-key.post-processor.spec.ts @@ -5,7 +5,6 @@ import { SortByKeyPostProcessor } from '../../src/post-processors/sort-by-key.po import { TranslationCollection } from '../../src/utils/translation.collection'; describe('SortByKeyPostProcessor', () => { - let processor: PostProcessorInterface; beforeEach(() => { @@ -14,20 +13,19 @@ describe('SortByKeyPostProcessor', () => { it('should sort keys alphanumerically', () => { const collection = new TranslationCollection({ - 'z': 'last value', - 'a': 'a value', + z: 'last value', + a: 'a value', '9': 'a numeric key', - 'b': 'another value' + 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' + a: 'a value', + b: 'another value', + z: 'last value' }); }); - }); diff --git a/tests/utils/translation.collection.spec.ts b/tests/utils/translation.collection.spec.ts index 785e4ac..05e1e32 100644 --- a/tests/utils/translation.collection.spec.ts +++ b/tests/utils/translation.collection.spec.ts @@ -3,7 +3,6 @@ import { expect } from 'chai'; import { TranslationCollection } from '../../src/utils/translation.collection'; describe('StringCollection', () => { - let collection: TranslationCollection; beforeEach(() => { @@ -64,12 +63,15 @@ describe('StringCollection', () => { it('should merge with other collection', () => { collection = collection.add('oldKey', 'oldVal'); const newCollection = new TranslationCollection({ newKey: 'newVal' }); - expect(collection.union(newCollection).values).to.deep.equal({ oldKey: 'oldVal', newKey: 'newVal' }); + expect(collection.union(newCollection).values).to.deep.equal({ + oldKey: 'oldVal', + newKey: 'newVal' + }); }); it('should intersect with passed collection', () => { collection = collection.addKeys(['red', 'green', 'blue']); - const newCollection = new TranslationCollection( { red: '', blue: '' }); + const newCollection = new TranslationCollection({ red: '', blue: '' }); expect(collection.intersect(newCollection).values).to.deep.equal({ red: '', blue: '' }); }); @@ -88,7 +90,10 @@ describe('StringCollection', () => { it('should map values', () => { collection = new TranslationCollection({ red: 'rød', green: 'grøn', blue: 'blå' }); collection = collection.map((key, val) => 'mapped value'); - expect(collection.values).to.deep.equal({ red: 'mapped value', green: 'mapped value', blue: 'mapped value' }); + expect(collection.values).to.deep.equal({ + red: 'mapped value', + green: 'mapped value', + blue: 'mapped value' + }); }); - });