-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(storybook): dont generate stories for stories
ISSUES CLOSED: #10286
- Loading branch information
Showing
7 changed files
with
182 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
import { joinPathFragments, Tree, writeJson } from '@nrwl/devkit'; | ||
import { | ||
overrideCollectionResolutionForTesting, | ||
wrapAngularDevkitSchematic, | ||
} from '@nrwl/devkit/ngcli-adapter'; | ||
import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing'; | ||
import { isTheFileAStory } from './utilities'; | ||
import { nxVersion, storybookVersion } from './versions'; | ||
|
||
const componentSchematic = wrapAngularDevkitSchematic( | ||
'@schematics/angular', | ||
'component' | ||
); | ||
const runAngularLibrarySchematic = wrapAngularDevkitSchematic( | ||
'@schematics/angular', | ||
'library' | ||
); | ||
const runAngularStorybookSchematic = wrapAngularDevkitSchematic( | ||
'@nrwl/angular', | ||
'storybook-configuration' | ||
); | ||
|
||
describe('testing utilities', () => { | ||
let appTree: Tree; | ||
|
||
beforeEach(async () => { | ||
overrideCollectionResolutionForTesting({ | ||
'@nrwl/storybook': joinPathFragments( | ||
__dirname, | ||
'../../../../generators.json' | ||
), | ||
}); | ||
|
||
appTree = createTreeWithEmptyWorkspace(); | ||
|
||
await runAngularLibrarySchematic(appTree, { | ||
name: 'test-ui-lib', | ||
}); | ||
|
||
await componentSchematic(appTree, { | ||
name: 'button', | ||
project: 'test-ui-lib', | ||
}); | ||
|
||
writeJson(appTree, 'package.json', { | ||
devDependencies: { | ||
'@nrwl/storybook': nxVersion, | ||
'@storybook/addon-knobs': storybookVersion, | ||
'@storybook/angular': storybookVersion, | ||
}, | ||
}); | ||
writeJson(appTree, 'test-ui-lib/tsconfig.json', {}); | ||
|
||
await runAngularStorybookSchematic(appTree, { | ||
name: 'test-ui-lib', | ||
configureCypress: true, | ||
}); | ||
|
||
appTree.write( | ||
`test-ui-lib/src/lib/button/button.component.stories.ts`, | ||
` | ||
import { Story, Meta } from '@storybook/react'; | ||
import { Button } from './button'; | ||
export default { | ||
component: Button, | ||
title: 'Button', | ||
} as Meta; | ||
const Template: Story = (args) => <Button {...args} />; | ||
export const Primary = Template.bind({}); | ||
Primary.args = {}; | ||
` | ||
); | ||
|
||
appTree.write( | ||
`test-ui-lib/src/lib/button/button.component.other.ts`, | ||
` | ||
import { Button } from './button'; | ||
// test test | ||
` | ||
); | ||
|
||
appTree.write( | ||
`test-ui-lib/src/lib/button/button.component.react-native.ts`, | ||
` | ||
import { storiesOf } from '@storybook/react-native'; | ||
// test test | ||
` | ||
); | ||
}); | ||
|
||
it('should verify it is story', () => { | ||
const fileIsStory = isTheFileAStory( | ||
appTree, | ||
'test-ui-lib/src/lib/button/button.component.stories.ts' | ||
); | ||
expect(fileIsStory).toBeTruthy(); | ||
}); | ||
|
||
it('should verify it is story for ReactNative', () => { | ||
const fileIsStory = isTheFileAStory( | ||
appTree, | ||
'test-ui-lib/src/lib/button/button.component.react-native.ts' | ||
); | ||
expect(fileIsStory).toBeTruthy(); | ||
}); | ||
|
||
it('should verify it is not a story', () => { | ||
const fileIsStory = isTheFileAStory( | ||
appTree, | ||
'test-ui-lib/src/lib/button/button.component.other.ts' | ||
); | ||
expect(fileIsStory).toBeFalsy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters