From a0b6eea992945ffdb92688b0a46f359f503b997d Mon Sep 17 00:00:00 2001 From: Hypnosphi Date: Thu, 29 Mar 2018 06:38:03 +0300 Subject: [PATCH] Run prettier --- .../manager/components/tests/Panel.test.js | 41 ++++++++----------- .../src/preview/components/Viewport.js | 2 +- .../preview/components/tests/Viewport.test.js | 24 ++++------- app/react-native/src/bin/storybook-start.js | 23 +++++------ 4 files changed, 36 insertions(+), 54 deletions(-) diff --git a/addons/viewport/src/manager/components/tests/Panel.test.js b/addons/viewport/src/manager/components/tests/Panel.test.js index fba44b3282d..ef7de9e61f3 100644 --- a/addons/viewport/src/manager/components/tests/Panel.test.js +++ b/addons/viewport/src/manager/components/tests/Panel.test.js @@ -184,12 +184,10 @@ describe('Viewport/Panel', () => { }); it('sets the state with the new information', () => { - expect(subject.instance().setState.mock.calls[0][0]).toEqual( - { - viewport: initialViewportAt(1), - isLandscape: false, - } - ); + expect(subject.instance().setState.mock.calls[0][0]).toEqual({ + viewport: initialViewportAt(1), + isLandscape: false, + }); }); }); @@ -213,21 +211,17 @@ describe('Viewport/Panel', () => { }); it('sets the state with the new information', () => { - expect(subject.instance().setState.mock.calls.length).toBe(2); - expect(subject.instance().setState.mock.calls[0][0]).toEqual( - { - storyDefaultViewport: 'iphone5' - } - ); + expect(subject.instance().setState.mock.calls).toHaveLength(2); + expect(subject.instance().setState.mock.calls[0][0]).toEqual({ + storyDefaultViewport: 'iphone5', + }); - expect(subject.instance().setState.mock.calls[1][0]).toEqual( - { - viewport: initialViewportAt(1), - isLandscape: false - } - ); + expect(subject.instance().setState.mock.calls[1][0]).toEqual({ + viewport: initialViewportAt(1), + isLandscape: false, + }); expect(typeof subject.instance().setState.mock.calls[1][1]).toEqual('function'); - + const updaterFunction = subject.instance().setState.mock.calls[1][1]; updaterFunction(); @@ -246,7 +240,7 @@ describe('Viewport/Panel', () => { beforeEach(() => { subject.instance().state = { ...subject.instance().state, - viewport: initialViewportAt(1) + viewport: initialViewportAt(1), }; subject.instance().emitViewportChanged(); }); @@ -254,10 +248,9 @@ describe('Viewport/Panel', () => { it('emits viewport changed event', () => { const viewport = transformedInitialViewports[initialViewportAt(1)]; - expect(props.channel.emit).toHaveBeenCalledWith( - 'addon:viewport:viewportChanged', - { viewport } - ); + expect(props.channel.emit).toHaveBeenCalledWith('addon:viewport:viewportChanged', { + viewport, + }); }); }); diff --git a/addons/viewport/src/preview/components/Viewport.js b/addons/viewport/src/preview/components/Viewport.js index d46b63fe6b0..17c58b9321c 100644 --- a/addons/viewport/src/preview/components/Viewport.js +++ b/addons/viewport/src/preview/components/Viewport.js @@ -18,7 +18,7 @@ export default class Viewport extends React.Component { static defaultProps = { name: DEFAULT_VIEWPORT, - onViewportChange: noop + onViewportChange: noop, }; constructor(props) { diff --git a/addons/viewport/src/preview/components/tests/Viewport.test.js b/addons/viewport/src/preview/components/tests/Viewport.test.js index 90808228f38..8cbed9c09d4 100644 --- a/addons/viewport/src/preview/components/tests/Viewport.test.js +++ b/addons/viewport/src/preview/components/tests/Viewport.test.js @@ -49,10 +49,7 @@ describe('Viewport', () => { subject = shallow(); expect(channel.on).toHaveBeenCalledTimes(1); - expect(channel.on).toHaveBeenCalledWith( - 'addon:viewport:viewportChanged', - noop - ); + expect(channel.on).toHaveBeenCalledWith('addon:viewport:viewportChanged', noop); }); }); @@ -60,12 +57,9 @@ describe('Viewport', () => { it('removes viewport changes listener', () => { subject = shallow(); subject.unmount(); - + expect(channel.removeListener).toHaveBeenCalledTimes(1); - expect(channel.removeListener).toHaveBeenCalledWith( - 'addon:viewport:viewportChanged', - noop - ); + expect(channel.removeListener).toHaveBeenCalledWith('addon:viewport:viewportChanged', noop); }); }); @@ -74,7 +68,7 @@ describe('Viewport', () => { const propsWithCallback = { name: 'unknown', children: 'do not exist', - onViewportChange: jest.fn() + onViewportChange: jest.fn(), }; beforeAll(() => { @@ -87,15 +81,13 @@ describe('Viewport', () => { it('calls onViewportChange with the newly selected viewport', () => { emitter.emit(VIEWPORT_CHANGED_EVENT_ID, { - viewport: INITIAL_VIEWPORTS.iphone5 + viewport: INITIAL_VIEWPORTS.iphone5, }); expect(propsWithCallback.onViewportChange).toHaveBeenCalled(); - expect(propsWithCallback.onViewportChange).toHaveBeenCalledWith( - { - viewport: INITIAL_VIEWPORTS.iphone5 - } - ); + expect(propsWithCallback.onViewportChange).toHaveBeenCalledWith({ + viewport: INITIAL_VIEWPORTS.iphone5, + }); }); }); }); diff --git a/app/react-native/src/bin/storybook-start.js b/app/react-native/src/bin/storybook-start.js index fa39e6c7e7f..203b0dfcb3a 100644 --- a/app/react-native/src/bin/storybook-start.js +++ b/app/react-native/src/bin/storybook-start.js @@ -58,27 +58,24 @@ if (!program.skipPackager) { roots = roots.concat(program.root.split(',').map(root => path.resolve(root))); } - try { - // eslint-disable-next-line global-require - require("babel-register")({ - "presets": ["flow"], + // eslint-disable-next-line global-require + require('babel-register')({ + presets: ['flow'], ignore: false, - babelrc: false}); + babelrc: false, + }); - // eslint-disable-next-line global-require + // eslint-disable-next-line global-require const findSymlinkedModules = require('react-native/local-cli/util/findSymlinkedModules'); - symlinks = roots.reduce( - (arr, rootPath) => arr.concat(findSymlinkedModules(rootPath, roots)), - [...roots] - ); + symlinks = roots.reduce((arr, rootPath) => arr.concat(findSymlinkedModules(rootPath, roots)), [ + ...roots, + ]); } catch (e) { console.warn(`Unable to load findSymlinksPaths: ${e.message}`, e); } - let projectRoots = (configDir === projectDir ? [] : [configDir]).concat( - symlinks - ); + let projectRoots = (configDir === projectDir ? [] : [configDir]).concat(symlinks); if (program.projectRoots) { projectRoots = projectRoots.concat(