@storybook/preview-api 7.0.20 → 7.0.22

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/preview-api",
3
- "version": "7.0.20",
3
+ "version": "7.0.22",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "storybook"
@@ -67,13 +67,13 @@
67
67
  "prep": "../../../scripts/prepare/bundle.ts"
68
68
  },
69
69
  "dependencies": {
70
- "@storybook/channel-postmessage": "7.0.20",
71
- "@storybook/channels": "7.0.20",
72
- "@storybook/client-logger": "7.0.20",
73
- "@storybook/core-events": "7.0.20",
70
+ "@storybook/channel-postmessage": "7.0.22",
71
+ "@storybook/channels": "7.0.22",
72
+ "@storybook/client-logger": "7.0.22",
73
+ "@storybook/core-events": "7.0.22",
74
74
  "@storybook/csf": "^0.1.0",
75
75
  "@storybook/global": "^5.0.0",
76
- "@storybook/types": "7.0.20",
76
+ "@storybook/types": "7.0.22",
77
77
  "@types/qs": "^6.9.5",
78
78
  "dequal": "^2.0.2",
79
79
  "lodash": "^4.17.21",
@@ -85,7 +85,7 @@
85
85
  },
86
86
  "devDependencies": {
87
87
  "@jest/globals": "^26.6.2",
88
- "@storybook/core-common": "7.0.20",
88
+ "@storybook/core-common": "7.0.22",
89
89
  "ansi-to-html": "^0.6.11",
90
90
  "react": "^16.14.0",
91
91
  "slash": "^5.0.0"
@@ -104,4 +104,4 @@
104
104
  ]
105
105
  },
106
106
  "gitHead": "9fb2573aa274f3f69d3358050e8df9c903e8245f"
107
- }
107
+ }
@@ -0,0 +1,55 @@
1
+ import { useParameter, useStoryContext } from './hooks';
2
+
3
+ describe('addons/hooks', () => {
4
+ beforeEach(() => {
5
+ global.STORYBOOK_HOOKS_CONTEXT = undefined;
6
+ });
7
+
8
+ afterEach(() => {
9
+ global.STORYBOOK_HOOKS_CONTEXT = undefined;
10
+ });
11
+
12
+ describe('useStoryContext', () => {
13
+ test('should throw', () => {
14
+ expect(() => useStoryContext()).toThrowError(
15
+ 'Storybook preview hooks can only be called inside decorators and story functions.'
16
+ );
17
+ });
18
+ });
19
+
20
+ describe('useParameter', () => {
21
+ beforeEach(() => {
22
+ global.STORYBOOK_HOOKS_CONTEXT = {
23
+ currentContext: {
24
+ parameters: {
25
+ 'undefined key': undefined,
26
+ 'null key': null,
27
+ 'false key': false,
28
+ 'zero key': 0,
29
+ 'object key': { defined: true },
30
+ },
31
+ },
32
+ };
33
+ });
34
+
35
+ test('undefined key', () => {
36
+ expect(useParameter('undefined key', 'undefined default')).toEqual('undefined default');
37
+ });
38
+
39
+ test('null key', () => {
40
+ expect(useParameter('null key', 'null default')).toEqual('null default');
41
+ });
42
+
43
+ test('false key', () => {
44
+ expect(useParameter('false key', 'false default')).toEqual(false);
45
+ });
46
+
47
+ test('zero key', () => {
48
+ expect(useParameter('zero key', 'zero default')).toEqual(0);
49
+ });
50
+
51
+ test('object key', () => {
52
+ expect(useParameter('object key', 'object default')).toMatchObject({ defined: true });
53
+ });
54
+ });
55
+ });
@@ -0,0 +1,41 @@
1
+ /* eslint-disable no-underscore-dangle */
2
+ /* eslint-disable @typescript-eslint/naming-convention */
3
+ declare module 'lazy-universal-dotenv';
4
+ declare module 'pnp-webpack-plugin';
5
+ declare module '@storybook/manager/paths';
6
+ declare module 'better-opn';
7
+ declare module 'open';
8
+ declare module '@aw-web-design/x-default-browser';
9
+
10
+ declare var FEATURES:
11
+ | {
12
+ storyStoreV7?: boolean;
13
+ storyStoreV7MdxErrors?: boolean;
14
+ argTypeTargetsV7?: boolean;
15
+ legacyMdx1?: boolean;
16
+ legacyDecoratorFileOrder?: boolean;
17
+ }
18
+ | undefined;
19
+
20
+ declare var STORIES: any;
21
+ declare var DOCS_OPTIONS: any;
22
+
23
+ // To enable user code to detect if it is running in Storybook
24
+ declare var IS_STORYBOOK: boolean;
25
+
26
+ // ClientApi (and StoreStore) are really singletons. However they are not created until the
27
+ // relevant framework instantiates them via `start.js`. The good news is this happens right away.
28
+ declare var __STORYBOOK_ADDONS_CHANNEL__: any;
29
+ declare var __STORYBOOK_ADDONS_PREVIEW: any;
30
+ declare var __STORYBOOK_CLIENT_API__: import('./modules/client-api/ClientApi').ClientApi<any>;
31
+ declare var __STORYBOOK_PREVIEW__: import('./modules/preview-web/PreviewWeb').PreviewWeb<any>;
32
+ declare var __STORYBOOK_STORY_STORE__: any;
33
+ declare var STORYBOOK_HOOKS_CONTEXT: any;
34
+ declare var LOGLEVEL: 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'silent' | undefined;
35
+
36
+ declare module 'ansi-to-html';
37
+ declare class AnsiToHtml {
38
+ constructor(options: { escapeHtml: boolean });
39
+
40
+ toHtml: (ansi: string) => string;
41
+ }