Skip to content

Commit

Permalink
fix(nx): configure knobs correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
Isaac Mann authored and vsavkin committed Nov 8, 2019
1 parent 562e096 commit ae93a87
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
32 changes: 30 additions & 2 deletions e2e/storybook.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,31 @@ forEachCli(() => {
runCLI(
`generate @nrwl/storybook:configuration ${mylib} --no-interactive`
);

writeFileSync(
tmpProjPath(
`apps/${mylib}-e2e/src/integration/test-button/test-button.component.spec.ts`
),
`
describe('test-ui-lib3726865', () => {
it('should render the component', () => {
cy.visit('/iframe.html?id=testbuttoncomponent--primary&knob-buttonType=button&knob-style=default&knob-age&knob-isDisabled=false');
cy.get('proj-test-button').should('exist');
cy.get('button').should('not.be.disabled');
cy.get('button').should('have.class', 'default');
cy.contains('You are 0 years old.');
});
it('should adjust the knobs', () => {
cy.visit('/iframe.html?id=testbuttoncomponent--primary&knob-buttonType=button&knob-style=primary&knob-age=10&knob-isDisabled=true');
cy.get('button').should('be.disabled');
cy.get('button').should('have.class', 'primary');
cy.contains('You are 10 years old.');
});
});
`
);

runCLI(
`generate @nrwl/react:storybook-configuration ${mylib2} --configureCypress --no-interactive`
);
Expand Down Expand Up @@ -68,7 +93,7 @@ export class TestButtonComponent implements OnInit {
@Input('buttonType') type = 'button';
@Input() style: ButtonStyle = 'default';
@Input() age: number;
@Input() isOn = false;
@Input() isDisabled = false;
constructor() { }
Expand All @@ -83,7 +108,10 @@ export class TestButtonComponent implements OnInit {
tmpProjPath(
`libs/${libName}/src/lib/test-button/test-button.component.html`
),
`<button [attr.type]="type" [ngClass]="style"></button>`
`
<button [disabled]="isDisabled" [attr.type]="type" [ngClass]="style">Click me</button>
<p>You are {{age}} years old.</p>
`
);
runCLI(
`g @schematics/angular:component test-other --project=${libName} --no-interactive`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { configure } from '<%= uiFramework %>';
import { configure, addDecorator } from '<%= uiFramework %>';
import { withKnobs } from '@storybook/addon-knobs';

addDecorator(withKnobs);
configure(require.context('../src/lib', true, /\.stories\.ts$/), module);

0 comments on commit ae93a87

Please sign in to comment.