metro: inline-plugin-test: does not replace local variables

Reviewed By: fromcelticpark

Differential Revision: D7533450

fbshipit-source-id: 5f1d37ad3cd8ecd585d627edd501f732837f12c5
This commit is contained in:
Jean Lauliac 2018-04-06 06:23:56 -07:00 committed by Facebook Github Bot
parent 203bb0ddfd
commit caf4fe379f
1 changed files with 9 additions and 0 deletions

View File

@ -79,6 +79,15 @@ describe('inline constants', () => {
expect(toString(ast)).toEqual(normalize(code.replace(/__DEV__/, 'true')));
});
it("doesn't replace a local __DEV__ variable", () => {
const code = `function a() {
var __DEV__ = false;
var a = __DEV__ ? 1 : 2;
}`;
const {ast} = inline('arbitrary.js', {code}, {dev: true});
expect(toString(ast)).toEqual(normalize(code));
});
it('replaces Platform.OS in the code if Platform is a global', () => {
const code = `function a() {
var a = Platform.OS;