// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`macros Macros are applied in the order respecting plugins order: Macros are applied in the order respecting plugins order 1`] = `
import Wrap from "./fixtures/jsx-id-prefix.macro";
const bar = Wrap(<div id="d1"><p id="p1"></p></div>);
↓ ↓ ↓ ↓ ↓ ↓
const bar = Wrap(<div id="plugin-macro-d1"><p id="plugin-macro-p1"></p></div>);
`;
exports[`macros Supports named imports: Supports named imports 1`] = `
import {css as CSS, styled as STYLED} from './fixtures/emotion.macro'
const red = CSS\`
background-color: red;
\`
const Div = STYLED.div\`
composes: \${red}
color: blue;
\`
↓ ↓ ↓ ↓ ↓ ↓
const red = "background-color: red;";
const Div = STYLED.div\`undefined\`;
`;
exports[`macros Works as a JSXElement: Works as a JSXElement 1`] = `
import MyEval from './fixtures/eval.macro'
const x = <MyEval>34 + 45</MyEval>
↓ ↓ ↓ ↓ ↓ ↓
const x = 79;
`;
exports[`macros appends the npm URL for errors thrown by node modules with a slash: appends the npm URL for errors thrown by node modules with a slash 1`] = `
import errorThrower from 'babel-plugin-macros-test-error-thrower/macro'
errorThrower('hi')
↓ ↓ ↓ ↓ ↓ ↓
Error: not helpful Learn more: https://www.npmjs.com/package/babel-plugin-macros-test-error-thrower
`;
exports[`macros appends the npm URL for errors thrown by node modules: appends the npm URL for errors thrown by node modules 1`] = `
import errorThrower from 'babel-plugin-macros-test-error-thrower.macro'
errorThrower('hi')
↓ ↓ ↓ ↓ ↓ ↓
Error: not helpful Learn more: https://www.npmjs.com/package/babel-plugin-macros-test-error-thrower.macro
`;
exports[`macros does nothing but remove macros if it is unused: does nothing but remove macros if it is unused 1`] = `
import foo from "./fixtures/eval.macro";
const bar = 42;
↓ ↓ ↓ ↓ ↓ ↓
const bar = 42;
`;
exports[`macros forwards MacroErrors thrown by the macro: forwards MacroErrors thrown by the macro 1`] = `
import errorThrower from './fixtures/macro-error-thrower.macro'
errorThrower('hey')
↓ ↓ ↓ ↓ ↓ ↓
MacroError: very helpful
`;
exports[`macros macros can set their configName and get their config: macros can set their configName and get their config 1`] = `
import configured from './configurable.macro'
// eslint-disable-next-line babel/no-unused-expressions
configured\`stuff\`
↓ ↓ ↓ ↓ ↓ ↓
// eslint-disable-next-line babel/no-unused-expressions
configured\`stuff\`;
`;
exports[`macros optionally keep imports (import declaration): optionally keep imports (import declaration) 1`] = `
import macro from './fixtures/keep-imports.macro'
const red = macro('noop');
↓ ↓ ↓ ↓ ↓ ↓
import macro from './fixtures/keep-imports.macro';
const red = macro('noop');
`;
exports[`macros optionally keep imports (variable assignment): optionally keep imports (variable assignment) 1`] = `
const macro = require('./fixtures/keep-imports.macro')
const red = macro('noop');
↓ ↓ ↓ ↓ ↓ ↓
const macro = require('./fixtures/keep-imports.macro');
const red = macro('noop');
`;
exports[`macros optionally keep imports in combination with babel-preset-env (#80): optionally keep imports in combination with babel-preset-env (#80) 1`] = `
import macro from './fixtures/keep-imports.macro'
const red = macro('noop')
↓ ↓ ↓ ↓ ↓ ↓
import macro from './fixtures/keep-imports.macro';
const red = macro('noop');
`;
exports[`macros prepends the relative path for errors thrown by the macro: prepends the relative path for errors thrown by the macro 1`] = `
import errorThrower from './fixtures/error-thrower.macro'
errorThrower('hey')
↓ ↓ ↓ ↓ ↓ ↓
Error: very unhelpful
`;
exports[`macros raises an error if macro does not exist: raises an error if macro does not exist 1`] = `
import foo from './some-macros-that-doesnt-even-need-to-exist.macro'
export default 'something else'
↓ ↓ ↓ ↓ ↓ ↓
Error: Cannot find module './some-macros-that-doesnt-even-need-to-exist.macro' from '<PROJECT_ROOT>/src/__tests__'
`;
exports[`macros supports compiled macros (\`__esModule\` + \`export default\`): supports compiled macros (\`__esModule\` + \`export default\`) 1`] = `
import {css, styled} from './fixtures/emotion-esm.macro'
const red = css\`
background-color: red;
\`
const Div = styled.div\`
composes: \${red}
color: blue;
\`
↓ ↓ ↓ ↓ ↓ ↓
const red = css\`
background-color: red;
\`;
const Div = styled.div\`
composes: \${red}
color: blue;
\`;
`;
exports[`macros supports macros from node_modules: supports macros from node_modules 1`] = `
import fakeMacro from 'babel-plugin-macros-test-fake/macro'
fakeMacro('hi')
↓ ↓ ↓ ↓ ↓ ↓
fakeMacro('hi');
`;
exports[`macros throws an error if the macro is not properly wrapped: throws an error if the macro is not properly wrapped 1`] = `
import unwrapped from './fixtures/non-wrapped.macro'
unwrapped('hey')
↓ ↓ ↓ ↓ ↓ ↓
Error: https://github.com/kentcdodds/babel-plugin-macros/blob/master/other/docs/author.md#writing-a-macro
`;
exports[`macros when a plugin that replaces paths is used, macros still work properly: when a plugin that replaces paths is used, macros still work properly 1`] = `
import myEval from '../eval.macro'
const result = myEval\`+('4' + '2')\`
global.result = result
↓ ↓ ↓ ↓ ↓ ↓
const result = ("foobar", 42);
global.result = result;
`;
exports[`macros when configuration is specified in plugin options: when configuration is specified in plugin options 1`] = `
import configured from './configurable.macro'
// eslint-disable-next-line babel/no-unused-expressions
configured\`stuff\`
↓ ↓ ↓ ↓ ↓ ↓
// eslint-disable-next-line babel/no-unused-expressions
configured\`stuff\`;
`;
exports[`macros when configuration is specified in plugin options: when configuration is specified in plugin options 2`] = `
const configured = require('./configurable.macro')
// eslint-disable-next-line babel/no-unused-expressions
configured\`stuff\`
↓ ↓ ↓ ↓ ↓ ↓
// eslint-disable-next-line babel/no-unused-expressions
configured\`stuff\`;
`;
exports[`macros when configuration is specified incorrectly in plugin options: when configuration is specified incorrectly in plugin options 1`] = `
import configured from './configurable.macro'
// eslint-disable-next-line babel/no-unused-expressions
configured\`stuff\`
↓ ↓ ↓ ↓ ↓ ↓
// eslint-disable-next-line babel/no-unused-expressions
configured\`stuff\`;
`;
exports[`macros when plugin options configuration cannot be merged with file configuration: when plugin options configuration cannot be merged with file configuration 1`] = `
import configured from './configurable.macro'
// eslint-disable-next-line babel/no-unused-expressions
configured\`stuff\`
↓ ↓ ↓ ↓ ↓ ↓
Error: <PROJECT_ROOT>/src/__tests__/fixtures/primitive-config/babel-plugin-macros.config.js specified a configurableMacro config of type object, but the the macros plugin's options.configurableMacro did contain an object. Both configs must contain objects for their options to be mergeable.
`;
exports[`macros when there is an error reading the config, a helpful message is logged 1`] = `
Array [
There was an error trying to load the config "configurableMacro" for the macro imported from "./configurable.macro. Please see the error thrown for more information.,
]
`;
exports[`macros when there is an error reading the config, a helpful message is logged: when there is an error reading the config, a helpful message is logged 1`] = `
import configured from './configurable.macro'
// eslint-disable-next-line babel/no-unused-expressions
configured\`stuff\`
↓ ↓ ↓ ↓ ↓ ↓
Error: this is a cosmiconfig error
`;
exports[`macros when there is no config to load, then no config is passed: when there is no config to load, then no config is passed 1`] = `
import configured from './configurable.macro'
// eslint-disable-next-line babel/no-unused-expressions
configured\`stuff\`
↓ ↓ ↓ ↓ ↓ ↓
// eslint-disable-next-line babel/no-unused-expressions
configured\`stuff\`;
`;
exports[`macros works with function calls: works with function calls 1`] = `
import myEval from './fixtures/eval.macro'
const x = myEval('34 + 45')
↓ ↓ ↓ ↓ ↓ ↓
const x = 79;
`;
exports[`macros works with import: works with import 1`] = `
import myEval from './fixtures/eval.macro'
const x = myEval\`34 + 45\`
↓ ↓ ↓ ↓ ↓ ↓
const x = 79;
`;
exports[`macros works with require destructuring and aliasing: works with require destructuring and aliasing 1`] = `
const {css: CSS, styled: STYLED} = require('./fixtures/emotion.macro')
const red = CSS\`
background-color: red;
\`
const Div = STYLED.div\`
composes: \${red}
color: blue;
\`
↓ ↓ ↓ ↓ ↓ ↓
const red = "background-color: red;";
const Div = STYLED.div\`undefined\`;
`;
exports[`macros works with require destructuring: works with require destructuring 1`] = `
const {css, styled} = require('./fixtures/emotion.macro')
const red = css\`
background-color: red;
\`
const Div = styled.div\`
composes: \${red}
color: blue;
\`
↓ ↓ ↓ ↓ ↓ ↓
const red = "background-color: red;";
const Div = styled.div\`undefined\`;
`;
exports[`macros works with require: works with require 1`] = `
const evaler = require('./fixtures/eval.macro')
const x = evaler\`34 + 45\`
↓ ↓ ↓ ↓ ↓ ↓
const x = 79;
`;