import test from 'ava' import { transform } from 'babel-core' const transpile = src => { return transform(src, { plugins: './index' }).code.trim() } test('Generic functional export', t => { t.is( transpile(`export const a = ({ props, listeners }) =>
{props.msg}
`), `export const a = { functional: true, render: (h, { props, listeners }) =>
{props.msg}
};` ) }) test('Generic functional component', t => { t.is( transpile(`const a = ({ props, listeners }) =>
{props.msg}
`), `const a = { functional: true, render: (h, { props, listeners }) =>
{props.msg}
};` ) }) test('Generic functional export with "name" when NODE_ENV === "development"', t => { const nodeEnv = process.env.NODE_ENV process.env.NODE_ENV = 'development' t.is( transpile(`export const a = ({ props, listeners }) =>
{props.msg}
`), `export const a = { name: "a", functional: true, render: (h, { props, listeners }) =>
{props.msg}
};` ) process.env.NODE_ENV = nodeEnv }) test('Generic functional component with "name" when NODE_ENV === "development"', t => { const nodeEnv = process.env.NODE_ENV process.env.NODE_ENV = 'development' t.is( transpile(`const a = ({ props, listeners }) =>
{props.msg}
`), `const a = { name: "a", functional: true, render: (h, { props, listeners }) =>
{props.msg}
};` ) process.env.NODE_ENV = nodeEnv })