Skip to content

Commit

Permalink
Use babel-plugin-tester
Browse files Browse the repository at this point in the history
  • Loading branch information
apalm committed Dec 26, 2017
1 parent 5c9b5b7 commit 16946b4
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 16 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"babel-eslint": "7.2.3",
"babel-generator": "^6.26.0",
"babel-plugin-macros": "2.0.0",
"babel-plugin-tester": "^5.0.0",
"babel-plugin-transform-async-to-generator": "6.24.1",
"babel-plugin-transform-es2015-modules-commonjs": "6.24.1",
"babel-plugin-transform-flow-strip-types": "6.22.0",
Expand Down
25 changes: 11 additions & 14 deletions packages/babel-plugin-relay/__tests__/BabelPluginRelayMacro-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,16 @@

require('configureForRelayOSS');

const babel = require('babel-core');
const pluginTester = require('babel-plugin-tester');
const plugin = require('babel-plugin-macros');

describe('BabelPluginRelayMacro', () => {
test('works', () => {
const basic = `
pluginTester({
plugin,
snapshot: true,
title: 'BabelPluginRelayMacro',
babelOptions: {filename: __filename, parserOpts: {plugins: ['jsx']}},
tests: {
works: `
'use strict';
const {graphql} = require('../../react-relay/modern/ReactRelayGraphQL.macro');
Expand All @@ -32,14 +37,6 @@ describe('BabelPluginRelayMacro', () => {
}
}
\`;
`;
const {code} = babel.transform(basic, {
plugins: ['babel-plugin-macros'],
filename: __filename,
compact: false,
parserOpts: {plugins: ['jsx']},
babelrc: false,
});
expect(code).toMatchSnapshot();
});
`,
},
});
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`BabelPluginRelayMacro works 1`] = `
exports[`BabelPluginRelayMacro works: works 1`] = `
"
'use strict';
const {graphql} = require('../../react-relay/modern/ReactRelayGraphQL.macro');
const CompatProfilePic = require('CompatProfilePic');
const CompatViewerQuery = graphql\`
query CompatViewerQuery($id: ID!, $scale: Float = 1.5) {
node(id: $id) {
... on User {
id
...CompatProfilePic_user
}
}
}
\`;
↓ ↓ ↓ ↓ ↓ ↓
'use strict';
const CompatProfilePic = require('CompatProfilePic');
const CompatViewerQuery = function () {
Expand All @@ -14,5 +32,6 @@ const CompatViewerQuery = function () {
}
return require('./__generated__/CompatViewerQuery.graphql');
};"
};
"
`;
24 changes: 24 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,16 @@ babel-plugin-syntax-trailing-function-commas@^6.5.0, babel-plugin-syntax-trailin
version "6.22.0"
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-trailing-function-commas/-/babel-plugin-syntax-trailing-function-commas-6.22.0.tgz#ba0360937f8d06e40180a43fe0d5616fff532cf3"

babel-plugin-tester@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/babel-plugin-tester/-/babel-plugin-tester-5.0.0.tgz#d3387860311cbd8353746d3a8aaba7ad2446e470"
dependencies:
common-tags "^1.4.0"
invariant "^2.2.2"
lodash.merge "^4.6.0"
path-exists "^3.0.0"
strip-indent "^2.0.0"

[email protected]:
version "6.24.1"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-async-to-generator/-/babel-plugin-transform-async-to-generator-6.24.1.tgz#6536e378aff6cb1d5517ac0e40eb3e9fc8d08761"
Expand Down Expand Up @@ -1213,6 +1223,12 @@ commander@^2.8.1:
version "2.11.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.11.0.tgz#157152fd1e7a6c8d98a5b715cf376df928004563"

common-tags@^1.4.0:
version "1.6.0"
resolved "https://registry.yarnpkg.com/common-tags/-/common-tags-1.6.0.tgz#788e4bcc582f16993e5b2c92f76b1ccb80731537"
dependencies:
babel-runtime "^6.26.0"

component-emitter@^1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.2.1.tgz#137918d6d78283f7df7a6b7c5a63e140e69425e6"
Expand Down Expand Up @@ -3591,6 +3607,10 @@ lodash.mapvalues@^4.4.0:
version "4.6.0"
resolved "https://registry.yarnpkg.com/lodash.mapvalues/-/lodash.mapvalues-4.6.0.tgz#1bafa5005de9dd6f4f26668c30ca37230cc9689c"

lodash.merge@^4.6.0:
version "4.6.0"
resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.0.tgz#69884ba144ac33fe699737a6086deffadd0f89c5"

lodash.restparam@^3.0.0:
version "3.6.1"
resolved "https://registry.yarnpkg.com/lodash.restparam/-/lodash.restparam-3.6.1.tgz#936a4e309ef330a7645ed4145986c85ae5b20805"
Expand Down Expand Up @@ -5101,6 +5121,10 @@ strip-eof@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/strip-eof/-/strip-eof-1.0.0.tgz#bb43ff5598a6eb05d89b59fcd129c983313606bf"

strip-indent@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/strip-indent/-/strip-indent-2.0.0.tgz#5ef8db295d01e6ed6cbf7aab96998d7822527b68"

strip-json-comments@~2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a"
Expand Down

0 comments on commit 16946b4

Please sign in to comment.