BVB Source Codes

storybook Show babel_config.test.js Source code

Return Download storybook: download babel_config.test.js Source code - Download storybook Source code - Type:.js
  1. import mock from 'mock-fs';
  2. import loadBabelConfig from './babel_config';
  3.  
  4. describe('babel_config', () => {
  5.   // As the 'fs' is going to be mocked, let's call require.resolve
  6.   // so the require.cache has the correct route to the file.
  7.   // In fact let's use it in the tests :)
  8.   const babelPluginReactDocgenPath = require.resolve('babel-plugin-react-docgen');
  9.  
  10.   it('should return the config with the extra plugins when `plugins` is an array.', () => {
  11.     // Mock a simple `.babelrc` config file.
  12.     mock({
  13.       '.babelrc': `{
  14.         "presets": [
  15.           "es2015",
  16.           "foo-preset"
  17.         ],
  18.         "plugins": [
  19.           "foo-plugin"
  20.         ]
  21.       }`,
  22.     });
  23.  
  24.     const config = loadBabelConfig('.foo');
  25.  
  26.     expect(config.plugins).toEqual([
  27.       'foo-plugin',
  28.       [
  29.         babelPluginReactDocgenPath,
  30.         {
  31.           DOC_GEN_COLLECTION_NAME: 'STORYBOOK_REACT_CLASSES',
  32.         },
  33.       ],
  34.     ]);
  35.  
  36.     mock.restore();
  37.   });
  38.  
  39.   it('should return the config with the extra plugins when `plugins` is not an array.', () => {
  40.     // Mock a `.babelrc` config file with plugins key not being an array.
  41.     mock({
  42.       '.babelrc': `{
  43.         "presets": [
  44.           "es2015",
  45.           "foo-preset"
  46.         ],
  47.         "plugins": "bar-plugin"
  48.       }`,
  49.     });
  50.  
  51.     const config = loadBabelConfig('.bar');
  52.  
  53.     expect(config.plugins).toEqual([
  54.       'bar-plugin',
  55.       [
  56.         babelPluginReactDocgenPath,
  57.         {
  58.           DOC_GEN_COLLECTION_NAME: 'STORYBOOK_REACT_CLASSES',
  59.         },
  60.       ],
  61.     ]);
  62.  
  63.     mock.restore();
  64.   });
  65.  
  66.   it('should return the config only with the extra plugins when `plugins` is not present.', () => {
  67.     // Mock a `.babelrc` config file with no plugins key.
  68.     mock({
  69.       '.babelrc': `{
  70.         "presets": [
  71.           "es2015",
  72.           "foo-preset"
  73.         ]
  74.       }`,
  75.     });
  76.  
  77.     const config = loadBabelConfig('.biz');
  78.  
  79.     expect(config.plugins).toEqual([
  80.       [
  81.         babelPluginReactDocgenPath,
  82.         {
  83.           DOC_GEN_COLLECTION_NAME: 'STORYBOOK_REACT_CLASSES',
  84.         },
  85.       ],
  86.     ]);
  87.  
  88.     mock.restore();
  89.   });
  90. });
  91.  
downloadbabel_config.test.js Source code - Download storybook Source code
Related Source Codes/Software:
ionicons - The premium icon font for Ionic ... 2017-06-07
AsyncDisplayKit - Smooth asynchronous user interfaces for iOS apps. ... 2017-06-07
lottie-android - Render After Effects animations natively on Androi... 2017-06-07
parse-server - Parse-compatible API server module for Node/Expres... 2017-06-07
prettier - Prettier is an opinionated JavaScript formatter. ... 2017-06-08
inferno - An extremely fast, React-like JavaScript library f... 2017-06-08
guetzli - Perceptual JPEG encoder 2017-06-08
cs-video-courses - List of Computer Science courses with video lectur... 2017-06-08
interviews - Everything you need to know to get the job. 2017-06-08
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top