Skip to content

Commit

Permalink
feat(storybook): generate typed import from storybook/react (#12743)
Browse files Browse the repository at this point in the history
  • Loading branch information
rek committed Oct 27, 2022
1 parent 594c63b commit 6e5ebfa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe('react:component-story', () => {
it('should properly set up the story', () => {
expect(formatFile`${appTree.read(storyFilePath, 'utf-8')}`)
.toContain(formatFile`
import { ComponentStory, ComponentMeta } from '@storybook/react';
import type { ComponentStory, ComponentMeta } from '@storybook/react';
import { TestUiLib } from './test-ui-lib';
const Story: ComponentMeta<typeof TestUiLib> = {
Expand Down Expand Up @@ -149,7 +149,7 @@ describe('react:component-story', () => {
it('should create a story without controls', () => {
expect(formatFile`${appTree.read(storyFilePath, 'utf-8')}`)
.toContain(formatFile`
import { ComponentStory, ComponentMeta } from '@storybook/react';
import type { ComponentStory, ComponentMeta } from '@storybook/react';
import { Test } from './test-ui-lib';
const Story: ComponentMeta<typeof Test> = {
Expand Down Expand Up @@ -200,7 +200,7 @@ describe('react:component-story', () => {
it('should setup controls based on the component props', () => {
expect(formatFile`${appTree.read(storyFilePath, 'utf-8')}`)
.toContain(formatFile`
import { ComponentStory, ComponentMeta } from '@storybook/react';
import type { ComponentStory, ComponentMeta } from '@storybook/react';
import { Test } from './test-ui-lib';
const Story: ComponentMeta<typeof Test> = {
Expand Down Expand Up @@ -259,7 +259,7 @@ describe('react:component-story', () => {
it('should setup controls based on the component props', () => {
expect(formatFile`${appTree.read(storyFilePath, 'utf-8')}`)
.toContain(formatFile`
import { ComponentStory, ComponentMeta } from '@storybook/react';
import type { ComponentStory, ComponentMeta } from '@storybook/react';
import { Test } from './test-ui-lib';
const Story: ComponentMeta<typeof Test> = {
Expand Down Expand Up @@ -423,7 +423,7 @@ describe('react:component-story', () => {
it('should properly setup the controls based on the component props', () => {
expect(formatFile`${appTree.read(storyFilePath, 'utf-8')}`)
.toContain(formatFile`
import { ComponentStory, ComponentMeta } from '@storybook/react';
import type { ComponentStory, ComponentMeta } from '@storybook/react';
import { Test } from './test-ui-lib';
const Story: ComponentMeta<typeof Test> = {
Expand Down Expand Up @@ -556,7 +556,7 @@ describe('react:component-story', () => {
it('should properly setup the controls based on the component props', () => {
expect(formatFile`${appTree.read(storyFilePath, 'utf-8')}`)
.toContain(formatFile`
import { ComponentStory, ComponentMeta } from '@storybook/react';
import type { ComponentStory, ComponentMeta } from '@storybook/react';
import { Test } from './test-ui-lib';
const Story: ComponentMeta<typeof Test> = {
Expand Down Expand Up @@ -620,7 +620,7 @@ describe('react:component-story', () => {

expect(formatFile`${appTree.read(storyFilePathOne, 'utf-8')}`)
.toContain(formatFile`
import { ComponentStory, ComponentMeta } from '@storybook/react';
import type { ComponentStory, ComponentMeta } from '@storybook/react';
import { One } from './test-ui-lib';
const Story: ComponentMeta<typeof One> = {
Expand All @@ -637,7 +637,7 @@ describe('react:component-story', () => {

expect(formatFile`${appTree.read(storyFilePathTwo, 'utf-8')}`)
.toContain(formatFile`
import { ComponentStory, ComponentMeta } from '@storybook/react';
import type { ComponentStory, ComponentMeta } from '@storybook/react';
import { Two } from './test-ui-lib';
const Story: ComponentMeta<typeof Two> = {
Expand All @@ -654,7 +654,7 @@ describe('react:component-story', () => {

expect(formatFile`${appTree.read(storyFilePathThree, 'utf-8')}`)
.toContain(formatFile`
import { ComponentStory, ComponentMeta } from '@storybook/react';
import type { ComponentStory, ComponentMeta } from '@storybook/react';
import { Three } from './test-ui-lib';
const Story: ComponentMeta<typeof Three> = {
Expand Down Expand Up @@ -687,7 +687,7 @@ describe('react:component-story', () => {
it('should properly set up the story', () => {
expect(formatFile`${appTree.read(storyFilePath, 'utf-8')}`)
.toContain(formatFile`
import { ComponentStory, ComponentMeta } from '@storybook/react';
import type { ComponentStory, ComponentMeta } from '@storybook/react';
import { TestUiLib } from './test-ui-lib';
const Story: ComponentMeta<typeof TestUiLib> = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% if ( !isPlainJs ) { %>import { ComponentStory, ComponentMeta } from '@storybook/react';<% } %>
<% if ( !isPlainJs ) { %>import type { ComponentStory, ComponentMeta } from '@storybook/react';<% } %>
import<% if ( !isPlainJs ) { %> { <% } %> <%= componentName %> <% if ( !isPlainJs ) { %> } <% } %> from './<%= componentImportFileName %>';

<% if ( isPlainJs ) { %>
Expand Down

0 comments on commit 6e5ebfa

Please sign in to comment.