File size: 647 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
import { transformSync } from '@babel/core';
import wrapWarningWithDevCheck from '../wrap-warning-with-dev-check';
function babelTransform(code) {
return transformSync(code, {
configFile: false,
plugins: [wrapWarningWithDevCheck],
}).code;
}
describe('wrap-warning-with-dev-check', () => {
test('should wrap warning calls', () => {
expect(babelTransform("warn(condition, 'message');")).toEqual(
"__DEV__ ? warn(condition, 'message') : void 0;"
);
});
test('should not wrap other calls', () => {
expect(babelTransform("deprecate(fn, 'message');")).toEqual(
"deprecate(fn, 'message');"
);
});
});
|