|
|
|
@ -10,26 +10,23 @@ import common from '../common.mjs';
@@ -10,26 +10,23 @@ import common from '../common.mjs';
|
|
|
|
|
import I18N from '../i18n.mjs'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
//根据模板文件生成默认语言包
|
|
|
|
|
test('Init test', async (t) => { |
|
|
|
|
let initTest = async function(t) { |
|
|
|
|
const i18n = new I18N(); |
|
|
|
|
const res = await i18n.init(); |
|
|
|
|
|
|
|
|
|
assert.ok(res); |
|
|
|
|
}); |
|
|
|
|
*/ |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
//根据语言包生成对应语言的html
|
|
|
|
|
test('Build test', async (t) => { |
|
|
|
|
let buildTest = async function(t) { |
|
|
|
|
const i18n = new I18N(); |
|
|
|
|
const res = await i18n.build(); |
|
|
|
|
|
|
|
|
|
let lang = process.argv[3]; |
|
|
|
|
const res = await i18n.build(lang); |
|
|
|
|
|
|
|
|
|
assert.ok(res); |
|
|
|
|
}); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
test('Lang file content get test', async (t) => { |
|
|
|
|
let getLangKeys = async function(t) { |
|
|
|
|
const i18n = new I18N(); |
|
|
|
|
let langFiles = await i18n.getLangFiles('en-us'); |
|
|
|
|
const langJson = await readFile(i18n.langDir + langFiles[0], { encoding: 'utf8' }); |
|
|
|
@ -41,5 +38,31 @@ test('Lang file content get test', async (t) => {
@@ -41,5 +38,31 @@ test('Lang file content get test', async (t) => {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
assert.ok(langJson); |
|
|
|
|
}); |
|
|
|
|
*/ |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let command = process.argv[2]; |
|
|
|
|
if (!command) { |
|
|
|
|
console.error('Test command usage: node test/i18n.test.mjs "command"'); |
|
|
|
|
console.error('Test commands: init, build, langKeys'); |
|
|
|
|
}else { |
|
|
|
|
switch (command) { |
|
|
|
|
case 'init': |
|
|
|
|
//根据模板文件生成默认语言包
|
|
|
|
|
test('Init test', initTest); |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
case 'build': |
|
|
|
|
//根据语言包生成对应语言的html
|
|
|
|
|
test('Build test', buildTest); |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
case 'langKeys': |
|
|
|
|
test('Lang file content get test', getLangKeys); |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
default: |
|
|
|
|
console.error('Test command usage: node test/i18n.test.mjs "command"'); |
|
|
|
|
console.error('Test commands: init, build, langKeys'); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|