@storybook/angular 9.1.0-alpha.0 → 9.1.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build-schema.json +199 -0
- package/builders.json +14 -0
- package/dist/builders/build-storybook/index.js +31 -80
- package/dist/builders/start-storybook/index.js +31 -101
- package/dist/chunk-CUDJAP6K.mjs +3 -0
- package/dist/chunk-KMSSK3DZ.mjs +6 -0
- package/dist/chunk-LXSTVAFF.mjs +40 -0
- package/dist/client/config.d.ts +20 -6
- package/dist/client/config.js +49 -20
- package/dist/client/config.mjs +10 -13
- package/dist/client/docs/config.d.ts +6 -3
- package/dist/client/docs/config.js +18 -14
- package/dist/client/docs/config.mjs +6 -10
- package/dist/client/index.d.ts +144 -6
- package/dist/client/index.js +47 -30
- package/dist/client/index.mjs +3 -9
- package/dist/client/preview-prod.d.ts +2 -1
- package/dist/client/preview-prod.js +5 -4
- package/dist/client/preview-prod.mjs +1 -0
- package/dist/index.d.ts +59 -2
- package/dist/index.js +47 -29
- package/dist/index.mjs +3 -13
- package/dist/preset.js +8 -38
- package/dist/server/framework-preset-angular-cli.js +20 -83
- package/dist/server/framework-preset-angular-ivy.js +6 -59
- package/dist/{client/types.d.ts → types-3b0b7107.d.ts} +9 -9
- package/package.json +71 -24
- package/start-schema.json +234 -0
- package/dist/builders/build-storybook/index.d.ts +0 -25
- package/dist/builders/build-storybook/index.mjs +0 -78
- package/dist/builders/build-storybook/index.spec.d.ts +0 -1
- package/dist/builders/build-storybook/index.spec.js +0 -222
- package/dist/builders/build-storybook/index.spec.mjs +0 -187
- package/dist/builders/build-storybook/schema.json +0 -199
- package/dist/builders/builders.json +0 -14
- package/dist/builders/start-storybook/index.d.ts +0 -21
- package/dist/builders/start-storybook/index.mjs +0 -99
- package/dist/builders/start-storybook/index.spec.d.ts +0 -1
- package/dist/builders/start-storybook/index.spec.js +0 -188
- package/dist/builders/start-storybook/index.spec.mjs +0 -186
- package/dist/builders/start-storybook/schema.json +0 -234
- package/dist/builders/utils/error-handler.d.ts +0 -2
- package/dist/builders/utils/error-handler.js +0 -38
- package/dist/builders/utils/error-handler.mjs +0 -33
- package/dist/builders/utils/run-compodoc.d.ts +0 -6
- package/dist/builders/utils/run-compodoc.js +0 -35
- package/dist/builders/utils/run-compodoc.mjs +0 -31
- package/dist/builders/utils/run-compodoc.spec.d.ts +0 -1
- package/dist/builders/utils/run-compodoc.spec.js +0 -76
- package/dist/builders/utils/run-compodoc.spec.mjs +0 -74
- package/dist/builders/utils/standalone-options.d.ts +0 -18
- package/dist/builders/utils/standalone-options.js +0 -2
- package/dist/builders/utils/standalone-options.mjs +0 -1
- package/dist/client/angular-beta/AbstractRenderer.d.ts +0 -75
- package/dist/client/angular-beta/AbstractRenderer.js +0 -201
- package/dist/client/angular-beta/AbstractRenderer.mjs +0 -164
- package/dist/client/angular-beta/CanvasRenderer.d.ts +0 -12
- package/dist/client/angular-beta/CanvasRenderer.js +0 -13
- package/dist/client/angular-beta/CanvasRenderer.mjs +0 -9
- package/dist/client/angular-beta/ComputesTemplateFromComponent.d.ts +0 -24
- package/dist/client/angular-beta/ComputesTemplateFromComponent.js +0 -160
- package/dist/client/angular-beta/ComputesTemplateFromComponent.mjs +0 -154
- package/dist/client/angular-beta/ComputesTemplateFromComponent.test.d.ts +0 -1
- package/dist/client/angular-beta/ComputesTemplateFromComponent.test.js +0 -730
- package/dist/client/angular-beta/ComputesTemplateFromComponent.test.mjs +0 -728
- package/dist/client/angular-beta/DocsRenderer.d.ts +0 -13
- package/dist/client/angular-beta/DocsRenderer.js +0 -39
- package/dist/client/angular-beta/DocsRenderer.mjs +0 -35
- package/dist/client/angular-beta/RendererFactory.d.ts +0 -11
- package/dist/client/angular-beta/RendererFactory.js +0 -56
- package/dist/client/angular-beta/RendererFactory.mjs +0 -50
- package/dist/client/angular-beta/RendererFactory.test.d.ts +0 -1
- package/dist/client/angular-beta/RendererFactory.test.js +0 -235
- package/dist/client/angular-beta/RendererFactory.test.mjs +0 -233
- package/dist/client/angular-beta/StorybookModule.d.ts +0 -8
- package/dist/client/angular-beta/StorybookModule.js +0 -27
- package/dist/client/angular-beta/StorybookModule.mjs +0 -23
- package/dist/client/angular-beta/StorybookModule.test.d.ts +0 -1
- package/dist/client/angular-beta/StorybookModule.test.js +0 -321
- package/dist/client/angular-beta/StorybookModule.test.mjs +0 -319
- package/dist/client/angular-beta/StorybookProvider.d.ts +0 -5
- package/dist/client/angular-beta/StorybookProvider.js +0 -26
- package/dist/client/angular-beta/StorybookProvider.mjs +0 -22
- package/dist/client/angular-beta/StorybookWrapperComponent.d.ts +0 -13
- package/dist/client/angular-beta/StorybookWrapperComponent.js +0 -127
- package/dist/client/angular-beta/StorybookWrapperComponent.mjs +0 -123
- package/dist/client/angular-beta/__testfixtures__/input.component.d.ts +0 -29
- package/dist/client/angular-beta/__testfixtures__/input.component.js +0 -76
- package/dist/client/angular-beta/__testfixtures__/input.component.mjs +0 -73
- package/dist/client/angular-beta/__testfixtures__/test.module.d.ts +0 -2
- package/dist/client/angular-beta/__testfixtures__/test.module.js +0 -20
- package/dist/client/angular-beta/__testfixtures__/test.module.mjs +0 -17
- package/dist/client/angular-beta/utils/BootstrapQueue.d.ts +0 -12
- package/dist/client/angular-beta/utils/BootstrapQueue.js +0 -86
- package/dist/client/angular-beta/utils/BootstrapQueue.mjs +0 -49
- package/dist/client/angular-beta/utils/BootstrapQueue.test.d.ts +0 -1
- package/dist/client/angular-beta/utils/BootstrapQueue.test.js +0 -164
- package/dist/client/angular-beta/utils/BootstrapQueue.test.mjs +0 -162
- package/dist/client/angular-beta/utils/NgComponentAnalyzer.d.ts +0 -22
- package/dist/client/angular-beta/utils/NgComponentAnalyzer.js +0 -93
- package/dist/client/angular-beta/utils/NgComponentAnalyzer.mjs +0 -84
- package/dist/client/angular-beta/utils/NgComponentAnalyzer.test.d.ts +0 -1
- package/dist/client/angular-beta/utils/NgComponentAnalyzer.test.js +0 -388
- package/dist/client/angular-beta/utils/NgComponentAnalyzer.test.mjs +0 -386
- package/dist/client/angular-beta/utils/NgModulesAnalyzer.d.ts +0 -6
- package/dist/client/angular-beta/utils/NgModulesAnalyzer.js +0 -41
- package/dist/client/angular-beta/utils/NgModulesAnalyzer.mjs +0 -37
- package/dist/client/angular-beta/utils/NgModulesAnalyzer.test.d.ts +0 -1
- package/dist/client/angular-beta/utils/NgModulesAnalyzer.test.js +0 -24
- package/dist/client/angular-beta/utils/NgModulesAnalyzer.test.mjs +0 -22
- package/dist/client/angular-beta/utils/PropertyExtractor.d.ts +0 -30
- package/dist/client/angular-beta/utils/PropertyExtractor.js +0 -196
- package/dist/client/angular-beta/utils/PropertyExtractor.mjs +0 -158
- package/dist/client/angular-beta/utils/PropertyExtractor.test.d.ts +0 -1
- package/dist/client/angular-beta/utils/PropertyExtractor.test.js +0 -177
- package/dist/client/angular-beta/utils/PropertyExtractor.test.mjs +0 -175
- package/dist/client/angular-beta/utils/StoryUID.d.ts +0 -22
- package/dist/client/angular-beta/utils/StoryUID.js +0 -43
- package/dist/client/angular-beta/utils/StoryUID.mjs +0 -38
- package/dist/client/argsToTemplate.d.ts +0 -56
- package/dist/client/argsToTemplate.js +0 -58
- package/dist/client/argsToTemplate.mjs +0 -55
- package/dist/client/argsToTemplate.test.d.ts +0 -1
- package/dist/client/argsToTemplate.test.js +0 -102
- package/dist/client/argsToTemplate.test.mjs +0 -100
- package/dist/client/compodoc-types.d.ts +0 -102
- package/dist/client/compodoc-types.js +0 -2
- package/dist/client/compodoc-types.mjs +0 -1
- package/dist/client/compodoc.d.ts +0 -12
- package/dist/client/compodoc.js +0 -261
- package/dist/client/compodoc.mjs +0 -248
- package/dist/client/compodoc.test.d.ts +0 -1
- package/dist/client/compodoc.test.js +0 -132
- package/dist/client/compodoc.test.mjs +0 -130
- package/dist/client/decorateStory.d.ts +0 -4
- package/dist/client/decorateStory.js +0 -48
- package/dist/client/decorateStory.mjs +0 -45
- package/dist/client/decorateStory.test.d.ts +0 -1
- package/dist/client/decorateStory.test.js +0 -306
- package/dist/client/decorateStory.test.mjs +0 -301
- package/dist/client/decorators.d.ts +0 -13
- package/dist/client/decorators.js +0 -69
- package/dist/client/decorators.mjs +0 -63
- package/dist/client/decorators.test.d.ts +0 -1
- package/dist/client/decorators.test.js +0 -159
- package/dist/client/decorators.test.mjs +0 -157
- package/dist/client/docs/__testfixtures__/doc-button/input.d.ts +0 -110
- package/dist/client/docs/__testfixtures__/doc-button/input.js +0 -204
- package/dist/client/docs/__testfixtures__/doc-button/input.mjs +0 -201
- package/dist/client/docs/__testfixtures__/doc-button/tsconfig.json +0 -7
- package/dist/client/docs/angular-properties.test.d.ts +0 -1
- package/dist/client/docs/angular-properties.test.js +0 -36
- package/dist/client/docs/angular-properties.test.mjs +0 -34
- package/dist/client/docs/sourceDecorator.d.ts +0 -10
- package/dist/client/docs/sourceDecorator.js +0 -53
- package/dist/client/docs/sourceDecorator.mjs +0 -48
- package/dist/client/globals.d.ts +0 -1
- package/dist/client/globals.js +0 -33
- package/dist/client/globals.mjs +0 -31
- package/dist/client/portable-stories.d.ts +0 -23
- package/dist/client/portable-stories.js +0 -62
- package/dist/client/portable-stories.mjs +0 -26
- package/dist/client/public-types.d.ts +0 -54
- package/dist/client/public-types.js +0 -2
- package/dist/client/public-types.mjs +0 -1
- package/dist/client/render.d.ts +0 -7
- package/dist/client/render.js +0 -19
- package/dist/client/render.mjs +0 -14
- package/dist/client/types.js +0 -2
- package/dist/client/types.mjs +0 -1
- package/dist/node/index.d.ts +0 -2
- package/dist/node/index.js +0 -6
- package/dist/node/index.mjs +0 -3
- package/dist/preset.d.ts +0 -5
- package/dist/preset.mjs +0 -34
- package/dist/renderer.d.ts +0 -6
- package/dist/renderer.js +0 -15
- package/dist/renderer.mjs +0 -6
- package/dist/server/__mocks-ng-workspace__/empty-projects-entry/angular.json +0 -4
- package/dist/server/__mocks-ng-workspace__/minimal-config/angular.json +0 -18
- package/dist/server/__mocks-ng-workspace__/minimal-config/src/main.d.ts +0 -1
- package/dist/server/__mocks-ng-workspace__/minimal-config/src/main.js +0 -5
- package/dist/server/__mocks-ng-workspace__/minimal-config/src/main.mjs +0 -2
- package/dist/server/__mocks-ng-workspace__/minimal-config/src/tsconfig.app.json +0 -9
- package/dist/server/__mocks-ng-workspace__/minimal-config/tsconfig.json +0 -13
- package/dist/server/__mocks-ng-workspace__/some-config/angular.json +0 -19
- package/dist/server/__mocks-ng-workspace__/some-config/src/main.d.ts +0 -1
- package/dist/server/__mocks-ng-workspace__/some-config/src/main.js +0 -5
- package/dist/server/__mocks-ng-workspace__/some-config/src/main.mjs +0 -2
- package/dist/server/__mocks-ng-workspace__/some-config/src/tsconfig.app.json +0 -9
- package/dist/server/__mocks-ng-workspace__/some-config/tsconfig.json +0 -13
- package/dist/server/__mocks-ng-workspace__/with-angularBrowserTarget/angular.json +0 -64
- package/dist/server/__mocks-ng-workspace__/with-angularBrowserTarget/src/main.d.ts +0 -1
- package/dist/server/__mocks-ng-workspace__/with-angularBrowserTarget/src/main.js +0 -5
- package/dist/server/__mocks-ng-workspace__/with-angularBrowserTarget/src/main.mjs +0 -2
- package/dist/server/__mocks-ng-workspace__/with-angularBrowserTarget/src/tsconfig.app.json +0 -9
- package/dist/server/__mocks-ng-workspace__/with-angularBrowserTarget/tsconfig.json +0 -13
- package/dist/server/__mocks-ng-workspace__/with-lib/angular.json +0 -28
- package/dist/server/__mocks-ng-workspace__/with-lib/projects/pattern-lib/src/main.d.ts +0 -1
- package/dist/server/__mocks-ng-workspace__/with-lib/projects/pattern-lib/src/main.js +0 -5
- package/dist/server/__mocks-ng-workspace__/with-lib/projects/pattern-lib/src/main.mjs +0 -2
- package/dist/server/__mocks-ng-workspace__/with-lib/projects/pattern-lib/tsconfig.lib.json +0 -20
- package/dist/server/__mocks-ng-workspace__/with-lib/tsconfig.json +0 -13
- package/dist/server/__mocks-ng-workspace__/with-nx/angular.json +0 -18
- package/dist/server/__mocks-ng-workspace__/with-nx/nx.json +0 -3
- package/dist/server/__mocks-ng-workspace__/with-nx/src/main.d.ts +0 -1
- package/dist/server/__mocks-ng-workspace__/with-nx/src/main.js +0 -5
- package/dist/server/__mocks-ng-workspace__/with-nx/src/main.mjs +0 -2
- package/dist/server/__mocks-ng-workspace__/with-nx/src/tsconfig.app.json +0 -8
- package/dist/server/__mocks-ng-workspace__/with-nx/tsconfig.json +0 -14
- package/dist/server/__mocks-ng-workspace__/with-nx-workspace/nx.json +0 -3
- package/dist/server/__mocks-ng-workspace__/with-nx-workspace/src/main.d.ts +0 -1
- package/dist/server/__mocks-ng-workspace__/with-nx-workspace/src/main.js +0 -5
- package/dist/server/__mocks-ng-workspace__/with-nx-workspace/src/main.mjs +0 -2
- package/dist/server/__mocks-ng-workspace__/with-nx-workspace/src/tsconfig.app.json +0 -8
- package/dist/server/__mocks-ng-workspace__/with-nx-workspace/tsconfig.json +0 -14
- package/dist/server/__mocks-ng-workspace__/with-nx-workspace/workspace.json +0 -18
- package/dist/server/__mocks-ng-workspace__/with-options-styles/angular.json +0 -18
- package/dist/server/__mocks-ng-workspace__/with-options-styles/src/main.d.ts +0 -1
- package/dist/server/__mocks-ng-workspace__/with-options-styles/src/main.js +0 -5
- package/dist/server/__mocks-ng-workspace__/with-options-styles/src/main.mjs +0 -2
- package/dist/server/__mocks-ng-workspace__/with-options-styles/src/tsconfig.app.json +0 -9
- package/dist/server/__mocks-ng-workspace__/with-options-styles/tsconfig.json +0 -13
- package/dist/server/__mocks-ng-workspace__/without-architect-build/angular.json +0 -5
- package/dist/server/__mocks-ng-workspace__/without-architect-build-options/angular.json +0 -11
- package/dist/server/__mocks-ng-workspace__/without-compatible-projects/angular.json +0 -7
- package/dist/server/__mocks-ng-workspace__/without-projects-entry/angular.json +0 -3
- package/dist/server/__mocks-ng-workspace__/without-projects-entry/projects/pattern-lib/src/main.d.ts +0 -1
- package/dist/server/__mocks-ng-workspace__/without-projects-entry/projects/pattern-lib/src/main.js +0 -5
- package/dist/server/__mocks-ng-workspace__/without-projects-entry/projects/pattern-lib/src/main.mjs +0 -2
- package/dist/server/__mocks-ng-workspace__/without-projects-entry/projects/pattern-lib/tsconfig.lib.json +0 -20
- package/dist/server/__mocks-ng-workspace__/without-projects-entry/tsconfig.json +0 -13
- package/dist/server/__mocks-ng-workspace__/without-tsConfig/angular.json +0 -16
- package/dist/server/__mocks-ng-workspace__/without-tsConfig/src/main.d.ts +0 -1
- package/dist/server/__mocks-ng-workspace__/without-tsConfig/src/main.js +0 -5
- package/dist/server/__mocks-ng-workspace__/without-tsConfig/src/main.mjs +0 -2
- package/dist/server/__mocks-ng-workspace__/without-tsConfig/src/tsconfig.app.json +0 -9
- package/dist/server/__mocks-ng-workspace__/without-tsConfig/tsconfig.json +0 -13
- package/dist/server/__tests__/angular.json +0 -96
- package/dist/server/angular-cli-webpack.d.ts +0 -1
- package/dist/server/angular-cli-webpack.js +0 -80
- package/dist/server/angular-cli-webpack.mjs +0 -80
- package/dist/server/framework-preset-angular-cli.d.ts +0 -3
- package/dist/server/framework-preset-angular-cli.mjs +0 -81
- package/dist/server/framework-preset-angular-ivy.d.ts +0 -10
- package/dist/server/framework-preset-angular-ivy.mjs +0 -56
- package/dist/server/plugins/storybook-normalize-angular-entry-plugin.d.ts +0 -12
- package/dist/server/plugins/storybook-normalize-angular-entry-plugin.js +0 -55
- package/dist/server/plugins/storybook-normalize-angular-entry-plugin.mjs +0 -52
- package/dist/server/preset-options.d.ts +0 -9
- package/dist/server/preset-options.js +0 -2
- package/dist/server/preset-options.mjs +0 -1
- package/dist/server/utils/filter-out-styling-rules.d.ts +0 -2
- package/dist/server/utils/filter-out-styling-rules.js +0 -17
- package/dist/server/utils/filter-out-styling-rules.mjs +0 -13
- package/dist/server/utils/module-is-available.d.ts +0 -1
- package/dist/server/utils/module-is-available.js +0 -13
- package/dist/server/utils/module-is-available.mjs +0 -9
- package/dist/test-setup.d.ts +0 -1
- package/dist/test-setup.js +0 -6
- package/dist/test-setup.mjs +0 -4
- package/dist/types.d.ts +0 -27
- package/dist/types.js +0 -2
- package/dist/types.mjs +0 -1
- package/scripts/postbuild.js +0 -17
- package/template/cli/.eslintrc.json +0 -5
|
@@ -1,301 +0,0 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
-
};
|
|
10
|
-
import { Component, Input, Output } from '@angular/core';
|
|
11
|
-
import { describe, expect, it } from 'vitest';
|
|
12
|
-
import { componentWrapperDecorator } from './decorators';
|
|
13
|
-
import decorateStory from './decorateStory';
|
|
14
|
-
// TODO: Fix. Test is infinitely running.
|
|
15
|
-
describe.skip('decorateStory', () => {
|
|
16
|
-
describe('angular behavior', () => {
|
|
17
|
-
it('should use componentWrapperDecorator with args', () => {
|
|
18
|
-
const decorators = [
|
|
19
|
-
componentWrapperDecorator(ParentComponent, ({ args }) => args),
|
|
20
|
-
componentWrapperDecorator((story) => `<grandparent [grandparentInput]="grandparentInput">${story}</grandparent>`, ({ args }) => args),
|
|
21
|
-
componentWrapperDecorator((story) => `<great-grandparent>${story}</great-grandparent>`),
|
|
22
|
-
];
|
|
23
|
-
const decorated = decorateStory(() => ({ template: '</child>' }), decorators);
|
|
24
|
-
expect(decorated(makeContext({
|
|
25
|
-
component: FooComponent,
|
|
26
|
-
args: {
|
|
27
|
-
parentInput: 'Parent input',
|
|
28
|
-
grandparentInput: 'grandparent input',
|
|
29
|
-
parentOutput: () => { },
|
|
30
|
-
},
|
|
31
|
-
}))).toEqual({
|
|
32
|
-
props: {
|
|
33
|
-
parentInput: 'Parent input',
|
|
34
|
-
grandparentInput: 'grandparent input',
|
|
35
|
-
parentOutput: expect.any(Function),
|
|
36
|
-
},
|
|
37
|
-
template: '<great-grandparent><grandparent [grandparentInput]="grandparentInput"><parent [parentInput]="parentInput" (parentOutput)="parentOutput($event)"></child></parent></grandparent></great-grandparent>',
|
|
38
|
-
userDefinedTemplate: true,
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
it('should use componentWrapperDecorator with input / output', () => {
|
|
42
|
-
const decorators = [
|
|
43
|
-
componentWrapperDecorator(ParentComponent, {
|
|
44
|
-
parentInput: 'Parent input',
|
|
45
|
-
parentOutput: () => { },
|
|
46
|
-
}),
|
|
47
|
-
componentWrapperDecorator((story) => `<grandparent [grandparentInput]="grandparentInput">${story}</grandparent>`, {
|
|
48
|
-
grandparentInput: 'Grandparent input',
|
|
49
|
-
sameInput: 'Should be override by story props',
|
|
50
|
-
}),
|
|
51
|
-
componentWrapperDecorator((story) => `<great-grandparent>${story}</great-grandparent>`),
|
|
52
|
-
];
|
|
53
|
-
const decorated = decorateStory(() => ({ template: '</child>', props: { sameInput: 'Story input' } }), decorators);
|
|
54
|
-
expect(decorated(makeContext({
|
|
55
|
-
component: FooComponent,
|
|
56
|
-
}))).toEqual({
|
|
57
|
-
props: {
|
|
58
|
-
parentInput: 'Parent input',
|
|
59
|
-
parentOutput: expect.any(Function),
|
|
60
|
-
grandparentInput: 'Grandparent input',
|
|
61
|
-
sameInput: 'Story input',
|
|
62
|
-
},
|
|
63
|
-
template: '<great-grandparent><grandparent [grandparentInput]="grandparentInput"><parent [parentInput]="parentInput" (parentOutput)="parentOutput($event)"></child></parent></grandparent></great-grandparent>',
|
|
64
|
-
userDefinedTemplate: true,
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
it('should use componentWrapperDecorator', () => {
|
|
68
|
-
const decorators = [
|
|
69
|
-
componentWrapperDecorator(ParentComponent),
|
|
70
|
-
componentWrapperDecorator((story) => `<grandparent>${story}</grandparent>`),
|
|
71
|
-
componentWrapperDecorator((story) => `<great-grandparent>${story}</great-grandparent>`),
|
|
72
|
-
];
|
|
73
|
-
const decorated = decorateStory(() => ({ template: '</child>' }), decorators);
|
|
74
|
-
expect(decorated(makeContext({ component: FooComponent }))).toEqual({
|
|
75
|
-
template: '<great-grandparent><grandparent><parent></child></parent></grandparent></great-grandparent>',
|
|
76
|
-
userDefinedTemplate: true,
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
it('should use template in preference to component parameters', () => {
|
|
80
|
-
const decorators = [
|
|
81
|
-
(s) => {
|
|
82
|
-
const story = s();
|
|
83
|
-
return {
|
|
84
|
-
...story,
|
|
85
|
-
template: `<parent>${story.template}</parent>`,
|
|
86
|
-
};
|
|
87
|
-
},
|
|
88
|
-
(s) => {
|
|
89
|
-
const story = s();
|
|
90
|
-
return {
|
|
91
|
-
...story,
|
|
92
|
-
template: `<grandparent>${story.template}</grandparent>`,
|
|
93
|
-
};
|
|
94
|
-
},
|
|
95
|
-
(s) => {
|
|
96
|
-
const story = s();
|
|
97
|
-
return {
|
|
98
|
-
...story,
|
|
99
|
-
template: `<great-grandparent>${story.template}</great-grandparent>`,
|
|
100
|
-
};
|
|
101
|
-
},
|
|
102
|
-
];
|
|
103
|
-
const decorated = decorateStory(() => ({ template: '</child>' }), decorators);
|
|
104
|
-
expect(decorated(makeContext({ component: FooComponent }))).toEqual({
|
|
105
|
-
template: '<great-grandparent><grandparent><parent></child></parent></grandparent></great-grandparent>',
|
|
106
|
-
userDefinedTemplate: true,
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
it('should include story templates in decorators', () => {
|
|
110
|
-
const decorators = [
|
|
111
|
-
(s) => {
|
|
112
|
-
const story = s();
|
|
113
|
-
return {
|
|
114
|
-
...story,
|
|
115
|
-
template: `<parent>${story.template}</parent>`,
|
|
116
|
-
};
|
|
117
|
-
},
|
|
118
|
-
(s) => {
|
|
119
|
-
const story = s();
|
|
120
|
-
return {
|
|
121
|
-
...story,
|
|
122
|
-
template: `<grandparent>${story.template}</grandparent>`,
|
|
123
|
-
};
|
|
124
|
-
},
|
|
125
|
-
(s) => {
|
|
126
|
-
const story = s();
|
|
127
|
-
return {
|
|
128
|
-
...story,
|
|
129
|
-
template: `<great-grandparent>${story.template}</great-grandparent>`,
|
|
130
|
-
};
|
|
131
|
-
},
|
|
132
|
-
];
|
|
133
|
-
const decorated = decorateStory(() => ({ template: '</child>' }), decorators);
|
|
134
|
-
expect(decorated(makeContext({}))).toEqual({
|
|
135
|
-
template: '<great-grandparent><grandparent><parent></child></parent></grandparent></great-grandparent>',
|
|
136
|
-
userDefinedTemplate: true,
|
|
137
|
-
});
|
|
138
|
-
});
|
|
139
|
-
it('should include story components in decorators', () => {
|
|
140
|
-
const decorators = [
|
|
141
|
-
(s) => {
|
|
142
|
-
const story = s();
|
|
143
|
-
return {
|
|
144
|
-
...story,
|
|
145
|
-
template: `<parent>${story.template}</parent>`,
|
|
146
|
-
};
|
|
147
|
-
},
|
|
148
|
-
(s) => {
|
|
149
|
-
const story = s();
|
|
150
|
-
return {
|
|
151
|
-
...story,
|
|
152
|
-
template: `<grandparent>${story.template}</grandparent>`,
|
|
153
|
-
};
|
|
154
|
-
},
|
|
155
|
-
(s) => {
|
|
156
|
-
const story = s();
|
|
157
|
-
return {
|
|
158
|
-
...story,
|
|
159
|
-
template: `<great-grandparent>${story.template}</great-grandparent>`,
|
|
160
|
-
};
|
|
161
|
-
},
|
|
162
|
-
];
|
|
163
|
-
const decorated = decorateStory(() => ({}), decorators);
|
|
164
|
-
expect(decorated(makeContext({ component: FooComponent }))).toEqual({
|
|
165
|
-
template: '<great-grandparent><grandparent><parent><foo></foo></parent></grandparent></great-grandparent>',
|
|
166
|
-
userDefinedTemplate: false,
|
|
167
|
-
});
|
|
168
|
-
});
|
|
169
|
-
it('should keep template with an empty value', () => {
|
|
170
|
-
const decorators = [
|
|
171
|
-
componentWrapperDecorator(ParentComponent),
|
|
172
|
-
];
|
|
173
|
-
const decorated = decorateStory(() => ({ template: '' }), decorators);
|
|
174
|
-
expect(decorated(makeContext({ component: FooComponent }))).toEqual({
|
|
175
|
-
template: '<parent></parent>',
|
|
176
|
-
});
|
|
177
|
-
});
|
|
178
|
-
it('should only keeps args with a control or an action in argTypes', () => {
|
|
179
|
-
const decorated = decorateStory((context) => ({
|
|
180
|
-
template: `Args available in the story : ${Object.keys(context.args).join()}`,
|
|
181
|
-
}), []);
|
|
182
|
-
expect(decorated(makeContext({
|
|
183
|
-
component: FooComponent,
|
|
184
|
-
argTypes: {
|
|
185
|
-
withControl: { control: { type: 'object' }, name: 'withControl' },
|
|
186
|
-
withAction: { action: 'onClick', name: 'withAction' },
|
|
187
|
-
toRemove: { name: 'toRemove' },
|
|
188
|
-
},
|
|
189
|
-
args: {
|
|
190
|
-
withControl: 'withControl',
|
|
191
|
-
withAction: () => ({}),
|
|
192
|
-
toRemove: 'toRemove',
|
|
193
|
-
},
|
|
194
|
-
}))).toEqual({
|
|
195
|
-
template: 'Args available in the story : withControl,withAction',
|
|
196
|
-
userDefinedTemplate: true,
|
|
197
|
-
});
|
|
198
|
-
});
|
|
199
|
-
});
|
|
200
|
-
describe('default behavior', () => {
|
|
201
|
-
it('calls decorators in out to in order', () => {
|
|
202
|
-
const decorators = [
|
|
203
|
-
(s) => {
|
|
204
|
-
const story = s();
|
|
205
|
-
return { ...story, props: { a: [...story.props.a, 1] } };
|
|
206
|
-
},
|
|
207
|
-
(s) => {
|
|
208
|
-
const story = s();
|
|
209
|
-
return { ...story, props: { a: [...story.props.a, 2] } };
|
|
210
|
-
},
|
|
211
|
-
(s) => {
|
|
212
|
-
const story = s();
|
|
213
|
-
return { ...story, props: { a: [...story.props.a, 3] } };
|
|
214
|
-
},
|
|
215
|
-
];
|
|
216
|
-
const decorated = decorateStory(() => ({ props: { a: [0] } }), decorators);
|
|
217
|
-
expect(decorated(makeContext({}))).toEqual({ props: { a: [0, 1, 2, 3] } });
|
|
218
|
-
});
|
|
219
|
-
it('passes context through to sub decorators', () => {
|
|
220
|
-
const decorators = [
|
|
221
|
-
(s, c) => {
|
|
222
|
-
const story = s({ ...c, k: 1 });
|
|
223
|
-
return { ...story, props: { a: [...story.props.a, c.k] } };
|
|
224
|
-
},
|
|
225
|
-
(s, c) => {
|
|
226
|
-
const story = s({ ...c, k: 2 });
|
|
227
|
-
return { ...story, props: { a: [...story.props.a, c.k] } };
|
|
228
|
-
},
|
|
229
|
-
(s, c) => {
|
|
230
|
-
const story = s({ ...c, k: 3 });
|
|
231
|
-
return { ...story, props: { a: [...story.props.a, c.k] } };
|
|
232
|
-
},
|
|
233
|
-
];
|
|
234
|
-
const decorated = decorateStory((c) => ({ props: { a: [c.k] } }), decorators);
|
|
235
|
-
expect(decorated(makeContext({ k: 0 }))).toEqual({ props: { a: [1, 2, 3, 0] } });
|
|
236
|
-
});
|
|
237
|
-
it('DOES NOT merge parameter or pass through parameters key in context', () => {
|
|
238
|
-
const decorators = [
|
|
239
|
-
(s, c) => {
|
|
240
|
-
const story = s({ ...c, k: 1, parameters: { p: 1 } });
|
|
241
|
-
return {
|
|
242
|
-
...story,
|
|
243
|
-
props: { a: [...story.props.a, c.k], p: [...story.props.p, c.parameters.p] },
|
|
244
|
-
};
|
|
245
|
-
},
|
|
246
|
-
(s, c) => {
|
|
247
|
-
const story = s({ ...c, k: 2, parameters: { p: 2 } });
|
|
248
|
-
return {
|
|
249
|
-
...story,
|
|
250
|
-
props: { a: [...story.props.a, c.k], p: [...story.props.p, c.parameters.p] },
|
|
251
|
-
};
|
|
252
|
-
},
|
|
253
|
-
(s, c) => {
|
|
254
|
-
const story = s({ ...c, k: 3, parameters: { p: 3 } });
|
|
255
|
-
return {
|
|
256
|
-
...story,
|
|
257
|
-
props: { a: [...story.props.a, c.k], p: [...story.props.p, c.parameters.p] },
|
|
258
|
-
};
|
|
259
|
-
},
|
|
260
|
-
];
|
|
261
|
-
const decorated = decorateStory((c) => ({ props: { a: [c.k], p: [c.parameters.p] } }), decorators);
|
|
262
|
-
expect(decorated(makeContext({ k: 0, parameters: { p: 0 } }))).toEqual({
|
|
263
|
-
props: { a: [1, 2, 3, 0], p: [0, 0, 0, 0] },
|
|
264
|
-
});
|
|
265
|
-
});
|
|
266
|
-
});
|
|
267
|
-
});
|
|
268
|
-
function makeContext(input) {
|
|
269
|
-
return {
|
|
270
|
-
id: 'id',
|
|
271
|
-
kind: 'kind',
|
|
272
|
-
name: 'name',
|
|
273
|
-
viewMode: 'story',
|
|
274
|
-
parameters: {},
|
|
275
|
-
...input,
|
|
276
|
-
};
|
|
277
|
-
}
|
|
278
|
-
let FooComponent = class FooComponent {
|
|
279
|
-
};
|
|
280
|
-
FooComponent = __decorate([
|
|
281
|
-
Component({
|
|
282
|
-
selector: 'foo',
|
|
283
|
-
template: `foo`,
|
|
284
|
-
})
|
|
285
|
-
], FooComponent);
|
|
286
|
-
let ParentComponent = class ParentComponent {
|
|
287
|
-
};
|
|
288
|
-
__decorate([
|
|
289
|
-
Input(),
|
|
290
|
-
__metadata("design:type", String)
|
|
291
|
-
], ParentComponent.prototype, "parentInput", void 0);
|
|
292
|
-
__decorate([
|
|
293
|
-
Output(),
|
|
294
|
-
__metadata("design:type", Object)
|
|
295
|
-
], ParentComponent.prototype, "parentOutput", void 0);
|
|
296
|
-
ParentComponent = __decorate([
|
|
297
|
-
Component({
|
|
298
|
-
selector: 'parent',
|
|
299
|
-
template: `<ng-content></ng-content>`,
|
|
300
|
-
})
|
|
301
|
-
], ParentComponent);
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { DecoratorFunction, StoryContext } from 'storybook/internal/types';
|
|
2
|
-
import { Type } from '@angular/core';
|
|
3
|
-
import { ApplicationConfig } from '@angular/platform-browser';
|
|
4
|
-
import { AngularRenderer, ICollection, NgModuleMetadata } from './types';
|
|
5
|
-
export declare const moduleMetadata: <TArgs = any>(metadata: Partial<NgModuleMetadata>) => DecoratorFunction<AngularRenderer, TArgs>;
|
|
6
|
-
/**
|
|
7
|
-
* Decorator to set the config options which are available during the application bootstrap
|
|
8
|
-
* operation
|
|
9
|
-
*/
|
|
10
|
-
export declare function applicationConfig<TArgs = any>(
|
|
11
|
-
/** Set of config options available during the application bootstrap operation. */
|
|
12
|
-
config: ApplicationConfig): DecoratorFunction<AngularRenderer, TArgs>;
|
|
13
|
-
export declare const componentWrapperDecorator: <TArgs = any>(element: Type<unknown> | ((story: string) => string), props?: ICollection | ((storyContext: StoryContext<AngularRenderer, TArgs>) => ICollection)) => DecoratorFunction<AngularRenderer, TArgs>;
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.componentWrapperDecorator = exports.moduleMetadata = void 0;
|
|
4
|
-
exports.applicationConfig = applicationConfig;
|
|
5
|
-
const ComputesTemplateFromComponent_1 = require("./angular-beta/ComputesTemplateFromComponent");
|
|
6
|
-
const NgComponentAnalyzer_1 = require("./angular-beta/utils/NgComponentAnalyzer");
|
|
7
|
-
// We use `any` here as the default type rather than `Args` because we need something that is
|
|
8
|
-
// castable to any component-specific args type when the user is being careful.
|
|
9
|
-
const moduleMetadata = (metadata) => (storyFn) => {
|
|
10
|
-
const story = storyFn();
|
|
11
|
-
const storyMetadata = story.moduleMetadata || {};
|
|
12
|
-
metadata = metadata || {};
|
|
13
|
-
return {
|
|
14
|
-
...story,
|
|
15
|
-
moduleMetadata: {
|
|
16
|
-
declarations: [...(metadata.declarations || []), ...(storyMetadata.declarations || [])],
|
|
17
|
-
entryComponents: [
|
|
18
|
-
...(metadata.entryComponents || []),
|
|
19
|
-
...(storyMetadata.entryComponents || []),
|
|
20
|
-
],
|
|
21
|
-
imports: [...(metadata.imports || []), ...(storyMetadata.imports || [])],
|
|
22
|
-
schemas: [...(metadata.schemas || []), ...(storyMetadata.schemas || [])],
|
|
23
|
-
providers: [...(metadata.providers || []), ...(storyMetadata.providers || [])],
|
|
24
|
-
},
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
exports.moduleMetadata = moduleMetadata;
|
|
28
|
-
/**
|
|
29
|
-
* Decorator to set the config options which are available during the application bootstrap
|
|
30
|
-
* operation
|
|
31
|
-
*/
|
|
32
|
-
function applicationConfig(
|
|
33
|
-
/** Set of config options available during the application bootstrap operation. */
|
|
34
|
-
config) {
|
|
35
|
-
return (storyFn) => {
|
|
36
|
-
const story = storyFn();
|
|
37
|
-
const storyConfig = story.applicationConfig;
|
|
38
|
-
return {
|
|
39
|
-
...story,
|
|
40
|
-
applicationConfig: storyConfig || config
|
|
41
|
-
? {
|
|
42
|
-
...config,
|
|
43
|
-
...storyConfig,
|
|
44
|
-
providers: [...(config?.providers || []), ...(storyConfig?.providers || [])],
|
|
45
|
-
}
|
|
46
|
-
: undefined,
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
const componentWrapperDecorator = (element, props) => (storyFn, storyContext) => {
|
|
51
|
-
const story = storyFn();
|
|
52
|
-
const currentProps = typeof props === 'function' ? props(storyContext) : props;
|
|
53
|
-
const template = (0, NgComponentAnalyzer_1.isComponent)(element)
|
|
54
|
-
? (0, ComputesTemplateFromComponent_1.computesTemplateFromComponent)(element, currentProps ?? {}, story.template)
|
|
55
|
-
: element(story.template);
|
|
56
|
-
return {
|
|
57
|
-
...story,
|
|
58
|
-
template,
|
|
59
|
-
...(currentProps || story.props
|
|
60
|
-
? {
|
|
61
|
-
props: {
|
|
62
|
-
...currentProps,
|
|
63
|
-
...story.props,
|
|
64
|
-
},
|
|
65
|
-
}
|
|
66
|
-
: {}),
|
|
67
|
-
};
|
|
68
|
-
};
|
|
69
|
-
exports.componentWrapperDecorator = componentWrapperDecorator;
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { computesTemplateFromComponent } from './angular-beta/ComputesTemplateFromComponent';
|
|
2
|
-
import { isComponent } from './angular-beta/utils/NgComponentAnalyzer';
|
|
3
|
-
// We use `any` here as the default type rather than `Args` because we need something that is
|
|
4
|
-
// castable to any component-specific args type when the user is being careful.
|
|
5
|
-
export const moduleMetadata = (metadata) => (storyFn) => {
|
|
6
|
-
const story = storyFn();
|
|
7
|
-
const storyMetadata = story.moduleMetadata || {};
|
|
8
|
-
metadata = metadata || {};
|
|
9
|
-
return {
|
|
10
|
-
...story,
|
|
11
|
-
moduleMetadata: {
|
|
12
|
-
declarations: [...(metadata.declarations || []), ...(storyMetadata.declarations || [])],
|
|
13
|
-
entryComponents: [
|
|
14
|
-
...(metadata.entryComponents || []),
|
|
15
|
-
...(storyMetadata.entryComponents || []),
|
|
16
|
-
],
|
|
17
|
-
imports: [...(metadata.imports || []), ...(storyMetadata.imports || [])],
|
|
18
|
-
schemas: [...(metadata.schemas || []), ...(storyMetadata.schemas || [])],
|
|
19
|
-
providers: [...(metadata.providers || []), ...(storyMetadata.providers || [])],
|
|
20
|
-
},
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* Decorator to set the config options which are available during the application bootstrap
|
|
25
|
-
* operation
|
|
26
|
-
*/
|
|
27
|
-
export function applicationConfig(
|
|
28
|
-
/** Set of config options available during the application bootstrap operation. */
|
|
29
|
-
config) {
|
|
30
|
-
return (storyFn) => {
|
|
31
|
-
const story = storyFn();
|
|
32
|
-
const storyConfig = story.applicationConfig;
|
|
33
|
-
return {
|
|
34
|
-
...story,
|
|
35
|
-
applicationConfig: storyConfig || config
|
|
36
|
-
? {
|
|
37
|
-
...config,
|
|
38
|
-
...storyConfig,
|
|
39
|
-
providers: [...(config?.providers || []), ...(storyConfig?.providers || [])],
|
|
40
|
-
}
|
|
41
|
-
: undefined,
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
export const componentWrapperDecorator = (element, props) => (storyFn, storyContext) => {
|
|
46
|
-
const story = storyFn();
|
|
47
|
-
const currentProps = typeof props === 'function' ? props(storyContext) : props;
|
|
48
|
-
const template = isComponent(element)
|
|
49
|
-
? computesTemplateFromComponent(element, currentProps ?? {}, story.template)
|
|
50
|
-
: element(story.template);
|
|
51
|
-
return {
|
|
52
|
-
...story,
|
|
53
|
-
template,
|
|
54
|
-
...(currentProps || story.props
|
|
55
|
-
? {
|
|
56
|
-
props: {
|
|
57
|
-
...currentProps,
|
|
58
|
-
...story.props,
|
|
59
|
-
},
|
|
60
|
-
}
|
|
61
|
-
: {}),
|
|
62
|
-
};
|
|
63
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
const vitest_1 = require("vitest");
|
|
10
|
-
const core_1 = require("@angular/core");
|
|
11
|
-
const decorators_1 = require("./decorators");
|
|
12
|
-
const defaultContext = {
|
|
13
|
-
componentId: 'unspecified',
|
|
14
|
-
kind: 'unspecified',
|
|
15
|
-
title: 'unspecified',
|
|
16
|
-
id: 'unspecified',
|
|
17
|
-
name: 'unspecified',
|
|
18
|
-
story: 'unspecified',
|
|
19
|
-
tags: [],
|
|
20
|
-
parameters: {},
|
|
21
|
-
initialArgs: {},
|
|
22
|
-
args: {},
|
|
23
|
-
argTypes: {},
|
|
24
|
-
globals: {},
|
|
25
|
-
globalTypes: {},
|
|
26
|
-
storyGlobals: {},
|
|
27
|
-
reporting: {
|
|
28
|
-
reports: [],
|
|
29
|
-
addReport: vitest_1.vi.fn(),
|
|
30
|
-
},
|
|
31
|
-
hooks: {},
|
|
32
|
-
loaded: {},
|
|
33
|
-
originalStoryFn: vitest_1.vi.fn(),
|
|
34
|
-
viewMode: 'story',
|
|
35
|
-
abortSignal: undefined,
|
|
36
|
-
canvasElement: undefined,
|
|
37
|
-
step: undefined,
|
|
38
|
-
context: undefined,
|
|
39
|
-
canvas: undefined,
|
|
40
|
-
userEvent: undefined,
|
|
41
|
-
mount: undefined,
|
|
42
|
-
};
|
|
43
|
-
defaultContext.context = defaultContext;
|
|
44
|
-
class MockModule {
|
|
45
|
-
}
|
|
46
|
-
class MockModuleTwo {
|
|
47
|
-
}
|
|
48
|
-
class MockService {
|
|
49
|
-
}
|
|
50
|
-
let MockComponent = class MockComponent {
|
|
51
|
-
};
|
|
52
|
-
MockComponent = __decorate([
|
|
53
|
-
(0, core_1.Component)({})
|
|
54
|
-
], MockComponent);
|
|
55
|
-
(0, vitest_1.describe)('applicationConfig', () => {
|
|
56
|
-
const provider1 = () => { };
|
|
57
|
-
const provider2 = () => { };
|
|
58
|
-
(0, vitest_1.it)('should apply global config', () => {
|
|
59
|
-
(0, vitest_1.expect)((0, decorators_1.applicationConfig)({
|
|
60
|
-
providers: [provider1],
|
|
61
|
-
})(() => ({}), defaultContext)).toEqual({
|
|
62
|
-
applicationConfig: {
|
|
63
|
-
providers: [provider1],
|
|
64
|
-
},
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
(0, vitest_1.it)('should apply story config', () => {
|
|
68
|
-
(0, vitest_1.expect)((0, decorators_1.applicationConfig)({
|
|
69
|
-
providers: [],
|
|
70
|
-
})(() => ({
|
|
71
|
-
applicationConfig: {
|
|
72
|
-
providers: [provider2],
|
|
73
|
-
},
|
|
74
|
-
}), {
|
|
75
|
-
...defaultContext,
|
|
76
|
-
})).toEqual({
|
|
77
|
-
applicationConfig: {
|
|
78
|
-
providers: [provider2],
|
|
79
|
-
},
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
(0, vitest_1.it)('should merge global and story config', () => {
|
|
83
|
-
(0, vitest_1.expect)((0, decorators_1.applicationConfig)({
|
|
84
|
-
providers: [provider1],
|
|
85
|
-
})(() => ({
|
|
86
|
-
applicationConfig: {
|
|
87
|
-
providers: [provider2],
|
|
88
|
-
},
|
|
89
|
-
}), {
|
|
90
|
-
...defaultContext,
|
|
91
|
-
})).toEqual({
|
|
92
|
-
applicationConfig: {
|
|
93
|
-
providers: [provider1, provider2],
|
|
94
|
-
},
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
(0, vitest_1.describe)('moduleMetadata', () => {
|
|
99
|
-
(0, vitest_1.it)('should add metadata to a story without it', () => {
|
|
100
|
-
const result = (0, decorators_1.moduleMetadata)({
|
|
101
|
-
imports: [MockModule],
|
|
102
|
-
providers: [MockService],
|
|
103
|
-
})(() => ({}),
|
|
104
|
-
// deepscan-disable-next-line
|
|
105
|
-
defaultContext);
|
|
106
|
-
(0, vitest_1.expect)(result).toEqual({
|
|
107
|
-
moduleMetadata: {
|
|
108
|
-
declarations: [],
|
|
109
|
-
entryComponents: [],
|
|
110
|
-
imports: [MockModule],
|
|
111
|
-
schemas: [],
|
|
112
|
-
providers: [MockService],
|
|
113
|
-
},
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
(0, vitest_1.it)('should combine with individual metadata on a story', () => {
|
|
117
|
-
const result = (0, decorators_1.moduleMetadata)({
|
|
118
|
-
imports: [MockModule],
|
|
119
|
-
})(() => ({
|
|
120
|
-
component: MockComponent,
|
|
121
|
-
moduleMetadata: {
|
|
122
|
-
imports: [MockModuleTwo],
|
|
123
|
-
providers: [MockService],
|
|
124
|
-
},
|
|
125
|
-
}),
|
|
126
|
-
// deepscan-disable-next-line
|
|
127
|
-
defaultContext);
|
|
128
|
-
(0, vitest_1.expect)(result).toEqual({
|
|
129
|
-
component: MockComponent,
|
|
130
|
-
moduleMetadata: {
|
|
131
|
-
declarations: [],
|
|
132
|
-
entryComponents: [],
|
|
133
|
-
imports: [MockModule, MockModuleTwo],
|
|
134
|
-
schemas: [],
|
|
135
|
-
providers: [MockService],
|
|
136
|
-
},
|
|
137
|
-
});
|
|
138
|
-
});
|
|
139
|
-
(0, vitest_1.it)('should return the original metadata if passed null', () => {
|
|
140
|
-
const result = (0, decorators_1.moduleMetadata)(null)(() => ({
|
|
141
|
-
component: MockComponent,
|
|
142
|
-
moduleMetadata: {
|
|
143
|
-
providers: [MockService],
|
|
144
|
-
},
|
|
145
|
-
}),
|
|
146
|
-
// deepscan-disable-next-line
|
|
147
|
-
defaultContext);
|
|
148
|
-
(0, vitest_1.expect)(result).toEqual({
|
|
149
|
-
component: MockComponent,
|
|
150
|
-
moduleMetadata: {
|
|
151
|
-
declarations: [],
|
|
152
|
-
entryComponents: [],
|
|
153
|
-
imports: [],
|
|
154
|
-
schemas: [],
|
|
155
|
-
providers: [MockService],
|
|
156
|
-
},
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
});
|