2018-03-01 09:19:59 -05:00
|
|
|
import { expect } from 'chai';
|
2018-03-01 09:52:16 -05:00
|
|
|
import { dirs } from './dirs';
|
|
|
|
import { dict, lookup, translate } from './translate';
|
2018-03-01 09:19:59 -05:00
|
|
|
|
|
|
|
|
|
|
|
describe('translate with dict', () => {
|
2018-03-01 09:52:16 -05:00
|
|
|
it('should ignore wrong entry', function () {
|
|
|
|
expect(dict.filter(entry => /^<div/.test(entry.original))).eql([]);
|
|
|
|
});
|
2018-03-01 09:19:59 -05:00
|
|
|
it('translate original english', () => {
|
|
|
|
expect(lookup('# Forms')[0].translation).eql('# 表单');
|
|
|
|
});
|
2018-03-01 09:52:16 -05:00
|
|
|
|
|
|
|
it('should auto translate based on dict', function () {
|
|
|
|
const fs = require('fs');
|
|
|
|
const content = fs.readFileSync(dirs.content + 'guide/forms.md', 'utf-8');
|
|
|
|
const result = translate(content);
|
|
|
|
fs.writeFileSync(dirs.content + 'guide/forms.md', result.join('\n\n'), 'utf-8');
|
|
|
|
});
|
|
|
|
|
2018-03-01 09:19:59 -05:00
|
|
|
});
|