Skip to content

Commit

Permalink
fix(angular): storybook config schematic from generating stories when…
Browse files Browse the repository at this point in the history
… generateStories false

ISSUES CLOSED: #2383
  • Loading branch information
BuckyMaler authored and vsavkin committed Feb 19, 2020
1 parent 16e90b3 commit 6cdc54b
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,45 @@ describe('schematic:configuration', () => {
appTree = await createTestUILib('test-ui-lib');
});

it('should only configure storybook', async () => {
const tree = await runSchematic(
'storybook-configuration',
<StorybookConfigureSchema>{
name: 'test-ui-lib',
configureCypress: false,
generateCypressSpecs: false,
generateStories: false
},
appTree
);
expect(tree.exists('libs/test-ui-lib/.storybook/addons.js')).toBeTruthy();
expect(tree.exists('libs/test-ui-lib/.storybook/config.js')).toBeTruthy();
expect(
tree.exists('libs/test-ui-lib/.storybook/tsconfig.json')
).toBeTruthy();
expect(tree.exists('apps/test-ui-lib-e2e/cypress.json')).toBeFalsy();
expect(
tree.exists(
'libs/test-ui-lib/src/lib/test-button/test-button.component.stories.ts'
)
).toBeFalsy();
expect(
tree.exists(
'libs/test-ui-lib/src/lib/test-other/test-other.component.stories.ts'
)
).toBeFalsy();
expect(
tree.exists(
'apps/test-ui-lib-e2e/src/integration/test-button/test-button.component.spec.ts'
)
).toBeFalsy();
expect(
tree.exists(
'apps/test-ui-lib-e2e/src/integration/test-other/test-other.component.spec.ts'
)
).toBeFalsy();
});

it('should configure everything at once', async () => {
const tree = await runSchematic(
'storybook-configuration',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,26 @@ import {
chain,
externalSchematic,
Rule,
schematic
schematic,
noop
} from '@angular-devkit/schematics';
import { StorybookStoriesSchema } from '../stories/stories';
import { StorybookConfigureSchema } from './schema';

export default function(schema: StorybookConfigureSchema): Rule {
if (schema.generateCypressSpecs && !schema.generateStories) {
throw new Error(
'Cannot set generateCypressSpecs to true when generateStories is set to false.'
);
}

return chain([
externalSchematic('@nrwl/storybook', 'configuration', {
name: schema.name,
uiFramework: '@storybook/angular',
configureCypress: schema.configureCypress
}),
generateStories(schema)
schema.generateStories ? generateStories(schema) : noop()
]);
}

Expand Down

0 comments on commit 6cdc54b

Please sign in to comment.