react-code-dataset / react-instantsearch /scripts /babel /__tests__ /wrap-warning-with-dev-check.test.js
Devendra174's picture
Upload folder using huggingface_hub
1e92f2d verified
raw
history blame
647 Bytes
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');"
);
});
});