Add a test
parent
7001bfbc92
commit
14a73ed9df
|
@ -0,0 +1,11 @@
|
||||||
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
|
exports[`works 1`] = `
|
||||||
|
"import { L } from \\"babel-plugin-react-translate/runtime\\";
|
||||||
|
var name = \\"John\\";
|
||||||
|
var foo = L(\\"\\\\u0401-Mobile\\");
|
||||||
|
foo = L(\\"\\\\u041C\\\\u0435\\\\u043D\\\\u044F \\\\u0437\\\\u043E\\\\u0432\\\\u0443\\\\u0442 {1}!\\", name) + \\" \\";
|
||||||
|
foo = \\" \\" + L(\\"\\\\u041C\\\\u0435\\\\u043D\\\\u044F \\\\u0437\\\\u043E\\\\u0432\\\\u0443\\\\u0442 {1}!\\", name);
|
||||||
|
foo = /*#__PURE__*/React.createElement(\\"span\\", null, L(\\"\\\\u041F\\\\u0440\\\\u0438\\\\u0432\\\\u0435\\\\u0442!\\"));
|
||||||
|
foo = L(\\"У меня много {1}: \\", L(\\"братьев\\"));"
|
||||||
|
`;
|
|
@ -0,0 +1,28 @@
|
||||||
|
const fs = require('fs');
|
||||||
|
const babel = require('@babel/core');
|
||||||
|
const jsx = require('@babel/plugin-transform-react-jsx');
|
||||||
|
const plugin = require('../');
|
||||||
|
|
||||||
|
var example = '\
|
||||||
|
var name = "John";\
|
||||||
|
var foo = "Ё-Mobile";\
|
||||||
|
foo = "Меня зовут "+name+"! ";\
|
||||||
|
foo = ` Меня зовут ${name}!`;\
|
||||||
|
foo = <span>Привет!</span>;\
|
||||||
|
foo = L("У меня много {1}: ", L("братьев"));\
|
||||||
|
';
|
||||||
|
|
||||||
|
it('works', () =>
|
||||||
|
{
|
||||||
|
const { code } = babel.transform(example, { filename: 'test', plugins: [ jsx, plugin ] });
|
||||||
|
expect(code).toMatchSnapshot();
|
||||||
|
expect(JSON.parse(fs.readFileSync('react-translate-output.json'))).toEqual({
|
||||||
|
test: [
|
||||||
|
"Ё-Mobile",
|
||||||
|
"Меня зовут {1}!",
|
||||||
|
"Привет!",
|
||||||
|
"У меня много {1}: ",
|
||||||
|
"братьев",
|
||||||
|
]
|
||||||
|
});
|
||||||
|
});
|
15
package.json
15
package.json
|
@ -4,7 +4,7 @@
|
||||||
"description": "Babel-based JS/JSX auto-translator for Russian language",
|
"description": "Babel-based JS/JSX auto-translator for Russian language",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "jest"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
@ -27,10 +27,21 @@
|
||||||
"russian",
|
"russian",
|
||||||
"translation"
|
"translation"
|
||||||
],
|
],
|
||||||
|
"files": [
|
||||||
|
"index.js",
|
||||||
|
"plural_ru.js",
|
||||||
|
"runtime.js",
|
||||||
|
"COPYING"
|
||||||
|
],
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Vitaliy Filippov",
|
"name": "Vitaliy Filippov",
|
||||||
"email": "vitalif@yourcmc.ru",
|
"email": "vitalif@yourcmc.ru",
|
||||||
"url": "http://yourcmc.ru/wiki/"
|
"url": "http://yourcmc.ru/wiki/"
|
||||||
},
|
},
|
||||||
"license": "LGPL-3.0"
|
"license": "LGPL-3.0",
|
||||||
|
"devDependencies": {
|
||||||
|
"@babel/core": "^7.15.0",
|
||||||
|
"@babel/plugin-transform-react-jsx": "^7.14.9",
|
||||||
|
"jest": "^27.1.0"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue