mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-11-03 20:45:58 +01:00 
			
		
		
		
	test: missing translator tests
This commit is contained in:
		@@ -41,6 +41,36 @@ describe('Translator shim', () => {
 | 
				
			|||||||
			assert.strictEqual(t, 'secret');
 | 
								assert.strictEqual(t, 'secret');
 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
	});
 | 
						});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						describe('translateKeys', () => {
 | 
				
			||||||
 | 
							it('should translate each key in array', async () => {
 | 
				
			||||||
 | 
								const translated = await shim.translateKeys(['[[global:home]]', '[[global:search]]'], 'en-GB');
 | 
				
			||||||
 | 
								assert.deepStrictEqual(translated, ['Home', 'Search']);
 | 
				
			||||||
 | 
							});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							it('should translate each key in array using a callback', (done) => {
 | 
				
			||||||
 | 
								shim.translateKeys(['[[global:save]]', '[[global:close]]'], 'en-GB', (translated) => {
 | 
				
			||||||
 | 
									assert.deepStrictEqual(translated, ['Save', 'Close']);
 | 
				
			||||||
 | 
									done();
 | 
				
			||||||
 | 
								});
 | 
				
			||||||
 | 
							});
 | 
				
			||||||
 | 
						});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						it('should load translations for language', (done) => {
 | 
				
			||||||
 | 
							shim.load('en-GB', 'global', (translations) => {
 | 
				
			||||||
 | 
								assert(translations);
 | 
				
			||||||
 | 
								assert(translations['header.profile']);
 | 
				
			||||||
 | 
								done();
 | 
				
			||||||
 | 
							});
 | 
				
			||||||
 | 
						});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						it('should get translations for language', (done) => {
 | 
				
			||||||
 | 
							shim.getTranslations('en-GB', 'global', (translations) => {
 | 
				
			||||||
 | 
								assert(translations);
 | 
				
			||||||
 | 
								assert(translations['header.profile']);
 | 
				
			||||||
 | 
								done();
 | 
				
			||||||
 | 
							});
 | 
				
			||||||
 | 
						});
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
describe('new Translator(language)', () => {
 | 
					describe('new Translator(language)', () => {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -567,5 +567,11 @@ describe('Utility Methods', () => {
 | 
				
			|||||||
			assert.strictEqual(el.find('#text').text(), 'Home');
 | 
								assert.strictEqual(el.find('#text').text(), 'Home');
 | 
				
			||||||
			assert.strictEqual(el.find('#search').attr('title'), 'Search');
 | 
								assert.strictEqual(el.find('#search').attr('title'), 'Search');
 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							it('should not error', (done) => {
 | 
				
			||||||
 | 
								shim.flush();
 | 
				
			||||||
 | 
								shim.flushNamespace();
 | 
				
			||||||
 | 
								done();
 | 
				
			||||||
 | 
							});
 | 
				
			||||||
	});
 | 
						});
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user