react-native-integrate
Version:
Automate integration of additional code into React Native projects
66 lines (65 loc) • 1.69 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
require('../../mocks/mockAll');
const buildGradleTask_1 = require("../../../tasks/buildGradleTask");
const applyContentModification_1 = require("../../../utils/applyContentModification");
describe('applyContentModification', () => {
it('should replace without search correctly', async () => {
let content = `
buildscript {
ext {
jcenter();
jcenter();
}
}
`;
content = await (0, applyContentModification_1.applyContentModification)({
action: {
block: 'buildscript.ext',
replace: 'google();',
},
findOrCreateBlock: buildGradleTask_1.findOrCreateBlock,
configPath: 'path/to/config',
packageName: 'package-name',
content,
indentation: 4,
});
expect(content).toMatch(`
buildscript {
ext {
google();
}
}
`);
});
it('should replace using script correctly', async () => {
let content = `
buildscript {
ext {
jcenter();
jcenter();
}
}
`;
content = await (0, applyContentModification_1.applyContentModification)({
action: {
block: 'buildscript.ext',
script: `
await replace("google();")
`,
},
findOrCreateBlock: buildGradleTask_1.findOrCreateBlock,
configPath: 'path/to/config',
packageName: 'package-name',
content,
indentation: 4,
});
expect(content).toMatch(`
buildscript {
ext {
google();
}
}
`);
});
});