mirror of
https://github.com/status-im/react-native.git
synced 2025-02-25 07:35:25 +00:00
Fixes #9294
Differential Revision: D3752878 fbshipit-source-id: f248082effde9133dd6a9edf8a2f2cfc05279eab
This commit is contained in:
parent
b59fde817f
commit
107fc72dab
20
local-cli/link/__tests__/android/makeStringsPatch.spec.js
Normal file
20
local-cli/link/__tests__/android/makeStringsPatch.spec.js
Normal file
@ -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;
|
||||
|
||||
module.exports = function makeStringsPatch(params, prefix) {
|
||||
const patch = Object.keys(params).map(param => {
|
||||
const name = toCamelCase(prefix) + '_' + param;
|
||||
return ' ' +
|
||||
`<string moduleConfig="true" name="${name}">${params[param]}</string>`;
|
||||
}).join('\n') + '\n';
|
||||
const values = Object.keys(params)
|
||||
.map(param => {
|
||||
const name = toCamelCase(prefix) + '_' + param;
|
||||
return ' ' +
|
||||
`<string moduleConfig="true" name="${name}">${params[param]}</string>`;
|
||||
});
|
||||
|
||||
const patch = values.length > 0
|
||||
? values.join('\n') + '\n'
|
||||
: '';
|
||||
|
||||
return {
|
||||
pattern: '<resources>\n',
|
||||
patch: patch,
|
||||
patch,
|
||||
};
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user