Fixes #9294
Differential Revision: D3752878 fbshipit-source-id: f248082effde9133dd6a9edf8a2f2cfc05279eab
This commit is contained in:
Родитель
b59fde817f
Коммит
107fc72dab
|
@ -0,0 +1,20 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
jest.autoMockOff();
|
||||||
|
|
||||||
|
const makeStringsPatch = require('../../android/patches/makeStringsPatch');
|
||||||
|
|
||||||
|
describe('makeStringsPatch', () => {
|
||||||
|
it('should export a patch with <string> element', () => {
|
||||||
|
const params = {
|
||||||
|
keyA: 'valueA',
|
||||||
|
};
|
||||||
|
|
||||||
|
expect(makeStringsPatch(params, 'module').patch)
|
||||||
|
.toContain('<string moduleConfig="true" name="module_keyA">valueA</string>');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should export an empty patch if no params given', () => {
|
||||||
|
expect(makeStringsPatch({}, 'module').patch).toBe('');
|
||||||
|
});
|
||||||
|
});
|
|
@ -1,14 +1,19 @@
|
||||||
const toCamelCase = require('lodash').camelCase;
|
const toCamelCase = require('lodash').camelCase;
|
||||||
|
|
||||||
module.exports = function makeStringsPatch(params, prefix) {
|
module.exports = function makeStringsPatch(params, prefix) {
|
||||||
const patch = Object.keys(params).map(param => {
|
const values = Object.keys(params)
|
||||||
const name = toCamelCase(prefix) + '_' + param;
|
.map(param => {
|
||||||
return ' ' +
|
const name = toCamelCase(prefix) + '_' + param;
|
||||||
`<string moduleConfig="true" name="${name}">${params[param]}</string>`;
|
return ' ' +
|
||||||
}).join('\n') + '\n';
|
`<string moduleConfig="true" name="${name}">${params[param]}</string>`;
|
||||||
|
});
|
||||||
|
|
||||||
|
const patch = values.length > 0
|
||||||
|
? values.join('\n') + '\n'
|
||||||
|
: '';
|
||||||
|
|
||||||
return {
|
return {
|
||||||
pattern: '<resources>\n',
|
pattern: '<resources>\n',
|
||||||
patch: patch,
|
patch,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Загрузка…
Ссылка в новой задаче