- (chore) update packages
- (refactor) use tsquery for querying AST - (feat) autodetect usage of marker function and remove --marker cli argument - (bugfix) extract strings when TranslateService is declared directly as a class parameter. Closes https://github.com/biesbjerg/ngx-translate-extract/issues/83 - (bugfix) handle split strings: marker('hello ' + 'world') is now extracted as a single string: 'hello world'
This commit is contained in:
		
							
								
								
									
										30
									
								
								tests/parsers/marker.parser.spec.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								tests/parsers/marker.parser.spec.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,30 @@ | ||||
| import { expect } from 'chai'; | ||||
|  | ||||
| import { MarkerParser } from '../../src/parsers/marker.parser'; | ||||
|  | ||||
| describe('MarkerParser', () => { | ||||
|  | ||||
| 	const componentFilename: string = 'test.component.ts'; | ||||
|  | ||||
| 	let parser: MarkerParser; | ||||
|  | ||||
| 	beforeEach(() => { | ||||
| 		parser = new MarkerParser(); | ||||
| 	}); | ||||
|  | ||||
|  | ||||
| 	it('should extract strings using marker function', () => { | ||||
| 		const contents = ` | ||||
| 			import { marker } from '@biesbjerg/ngx-translate-extract-marker'; | ||||
| 			marker('Hello world'); | ||||
| 			marker(['I', 'am', 'extracted']); | ||||
| 			otherFunction('But I am not'); | ||||
| 			marker(message || 'binary expression'); | ||||
| 			marker(message ? message : 'conditional operator'); | ||||
| 			marker('FOO.bar'); | ||||
| 		`; | ||||
| 		const keys = parser.extract(contents, componentFilename).keys(); | ||||
| 		expect(keys).to.deep.equal(['Hello world', 'I', 'am', 'extracted', 'binary expression', 'conditional operator', 'FOO.bar']); | ||||
| 	}); | ||||
|  | ||||
| }); | ||||
		Reference in New Issue
	
	Block a user