jest.autoMockOff(); import { renameEditorToMigrationComponent } from '../migrates/rename-editor-to-editor-migration-component'; import { createTransformer } from '../utils'; // This stays as require() since changing to import will trigger a linter error // Ignored via go/ees005 // eslint-disable-next-line import/no-commonjs const defineInlineTest = require('jscodeshift/dist/testUtils').defineInlineTest; const transformer = createTransformer('@atlaskit/editor-core', [renameEditorToMigrationComponent]); describe('Update Editor to EditorMigrationComponent', () => { defineInlineTest( { default: transformer, parser: 'tsx' }, {}, ` import React from 'react'; import { Editor } from '@atlaskit/editor-core'; export default () => ( ); `, // ----- ` import React from 'react'; import { EditorMigrationComponent as Editor } from '@atlaskit/editor-core'; export default () => ( ); `, // ----- 'update editor component', ); defineInlineTest( { default: transformer, parser: 'tsx' }, {}, ` import React from 'react'; import { Editor as AkEditor } from '@atlaskit/editor-core'; export default () => ( ); `, // ----- ` import React from 'react'; import { EditorMigrationComponent as AkEditor } from '@atlaskit/editor-core'; export default () => ( ); `, // ----- 'update editor component to keep same local name', ); defineInlineTest( { default: transformer, parser: 'tsx' }, {}, ` import React from 'react'; import { Editor as AkEditor, ContextPanel } from '@atlaskit/editor-core'; export default () => ( ); `, // ----- ` import React from 'react'; import { EditorMigrationComponent as AkEditor, ContextPanel } from '@atlaskit/editor-core'; export default () => ( ); `, // ----- 'update editor component to not modify other components', ); defineInlineTest( { default: transformer, parser: 'tsx' }, {}, ` import React from 'react'; import { ContextPanel } from '@atlaskit/editor-core'; export default () => (
); `, // ----- ` import React from 'react'; import { ContextPanel } from '@atlaskit/editor-core'; export default () => (
); `, // ----- 'nothing should change if there is no editor', ); defineInlineTest( { default: transformer, parser: 'tsx' }, {}, ` import React from 'react'; import SomethingElse, { Editor } from 'cool-package' import { Editor as AkEditor } from '@atlaskit/editor-core'; export default () => ( ); `, // ----- ` import React from 'react'; import SomethingElse, { Editor } from 'cool-package' import { EditorMigrationComponent as AkEditor } from '@atlaskit/editor-core'; export default () => ( ); `, // ----- 'should not change named exports from other packages that are called Editor', ); defineInlineTest( { default: transformer, parser: 'tsx' }, {}, ` import React from 'react'; import Editor from 'cool-package' import { Editor as AkEditor } from '@atlaskit/editor-core'; export default () => ( ); `, // ----- ` import React from 'react'; import Editor from 'cool-package' import { EditorMigrationComponent as AkEditor } from '@atlaskit/editor-core'; export default () => ( ); `, // ----- 'should not change exports from other packages that has a default export of Editor', ); });