@storybook/angular 8.0.0-alpha.3 → 8.0.0-alpha.5

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.
@@ -6,38 +6,41 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
6
6
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7
7
  };
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
+ const vitest_1 = require("vitest");
9
10
  const core_1 = require("@angular/core");
10
11
  const testing_1 = require("@angular/platform-browser-dynamic/testing");
11
12
  const platform_browser_dynamic_1 = require("@angular/platform-browser-dynamic");
12
13
  const CanvasRenderer_1 = require("./CanvasRenderer");
13
14
  const RendererFactory_1 = require("./RendererFactory");
14
15
  const DocsRenderer_1 = require("./DocsRenderer");
15
- jest.mock('@angular/platform-browser-dynamic');
16
- describe('RendererFactory', () => {
16
+ vitest_1.vi.mock('@angular/platform-browser-dynamic');
17
+ (0, vitest_1.describe)('RendererFactory', () => {
17
18
  let rendererFactory;
18
19
  let rootTargetDOMNode;
19
20
  let rootDocstargetDOMNode;
20
- beforeEach(async () => {
21
+ let storyInDocstargetDOMNode;
22
+ (0, vitest_1.beforeEach)(async () => {
21
23
  rendererFactory = new RendererFactory_1.RendererFactory();
22
24
  document.body.innerHTML =
23
- '<div id="storybook-root"></div><div id="root-docs"><div id="story-in-docs"></div></div>';
25
+ '<div id="storybook-root"></div><div id="root-docs"><div id="story-in-docs"></div></div>' +
26
+ '<div id="storybook-docs"></div>';
24
27
  rootTargetDOMNode = global.document.getElementById('storybook-root');
25
28
  rootDocstargetDOMNode = global.document.getElementById('root-docs');
26
29
  platform_browser_dynamic_1.platformBrowserDynamic.mockImplementation(testing_1.platformBrowserDynamicTesting);
27
- jest.spyOn(console, 'log').mockImplementation(() => { });
30
+ vitest_1.vi.spyOn(console, 'log').mockImplementation(() => { });
28
31
  });
29
32
  afterEach(() => {
30
- jest.clearAllMocks();
33
+ vitest_1.vi.clearAllMocks();
31
34
  // Necessary to avoid this error "Provided value for `preserveWhitespaces` can not be changed once it has been set." :
32
35
  // Source: https://github.com/angular/angular/commit/e342ffd855ffeb8af7067b42307ffa320d82177e#diff-92b125e532cc22977b46a91f068d6d7ea81fd61b772842a4a0212f1cfd875be6R28
33
36
  (0, core_1.ɵresetJitOptions)();
34
37
  });
35
- describe('CanvasRenderer', () => {
36
- it('should get CanvasRenderer instance', async () => {
38
+ (0, vitest_1.describe)('CanvasRenderer', () => {
39
+ (0, vitest_1.it)('should get CanvasRenderer instance', async () => {
37
40
  const render = await rendererFactory.getRendererInstance(rootTargetDOMNode);
38
- expect(render).toBeInstanceOf(CanvasRenderer_1.CanvasRenderer);
41
+ (0, vitest_1.expect)(render).toBeInstanceOf(CanvasRenderer_1.CanvasRenderer);
39
42
  });
40
- it('should render my-story for story template', async () => {
43
+ (0, vitest_1.it)('should render my-story for story template', async () => {
41
44
  const render = await rendererFactory.getRendererInstance(rootTargetDOMNode);
42
45
  await render?.render({
43
46
  storyFnAngular: {
@@ -47,9 +50,9 @@ describe('RendererFactory', () => {
47
50
  forced: false,
48
51
  targetDOMNode: rootTargetDOMNode,
49
52
  });
50
- expect(document.body.getElementsByTagName('storybook-root')[0].innerHTML).toBe('🦊');
53
+ (0, vitest_1.expect)(document.body.getElementsByTagName('storybook-root')[0].innerHTML).toBe('🦊');
51
54
  });
52
- it('should render my-story for story component', async () => {
55
+ (0, vitest_1.it)('should render my-story for story component', async () => {
53
56
  let FooComponent = class FooComponent {
54
57
  };
55
58
  FooComponent = __decorate([
@@ -64,9 +67,9 @@ describe('RendererFactory', () => {
64
67
  component: FooComponent,
65
68
  targetDOMNode: rootTargetDOMNode,
66
69
  });
67
- expect(document.body.getElementsByTagName('storybook-root')[0].innerHTML).toBe('<foo>🦊</foo><!--container-->');
70
+ (0, vitest_1.expect)(document.body.getElementsByTagName('storybook-root')[0].innerHTML).toBe('<foo>🦊</foo><!--container-->');
68
71
  });
69
- it('should handle circular reference in moduleMetadata', async () => {
72
+ (0, vitest_1.it)('should handle circular reference in moduleMetadata', async () => {
70
73
  class Thing {
71
74
  constructor() {
72
75
  this.token = this;
@@ -83,10 +86,10 @@ describe('RendererFactory', () => {
83
86
  forced: false,
84
87
  targetDOMNode: rootTargetDOMNode,
85
88
  });
86
- expect(document.body.getElementsByTagName('storybook-root')[0].innerHTML).toBe('🦊');
89
+ (0, vitest_1.expect)(document.body.getElementsByTagName('storybook-root')[0].innerHTML).toBe('🦊');
87
90
  });
88
- describe('when forced=true', () => {
89
- beforeEach(async () => {
91
+ (0, vitest_1.describe)('when forced=true', () => {
92
+ (0, vitest_1.beforeEach)(async () => {
90
93
  // Init first render
91
94
  const render = await rendererFactory.getRendererInstance(rootTargetDOMNode);
92
95
  await render?.render({
@@ -101,10 +104,10 @@ describe('RendererFactory', () => {
101
104
  targetDOMNode: rootTargetDOMNode,
102
105
  });
103
106
  });
104
- it('should be rendered a first time', async () => {
105
- expect(document.body.getElementsByTagName('storybook-root')[0].innerHTML).toBe('🦊: Fox');
107
+ (0, vitest_1.it)('should be rendered a first time', async () => {
108
+ (0, vitest_1.expect)(document.body.getElementsByTagName('storybook-root')[0].innerHTML).toBe('🦊: Fox');
106
109
  });
107
- it('should not be re-rendered when only props change', async () => {
110
+ (0, vitest_1.it)('should not be re-rendered when only props change', async () => {
108
111
  // only props change
109
112
  const render = await rendererFactory.getRendererInstance(rootTargetDOMNode);
110
113
  await render?.render({
@@ -116,9 +119,9 @@ describe('RendererFactory', () => {
116
119
  forced: true,
117
120
  targetDOMNode: rootTargetDOMNode,
118
121
  });
119
- expect(document.body.getElementsByTagName('storybook-root')[0].innerHTML).toBe('👾: Fox');
122
+ (0, vitest_1.expect)(document.body.getElementsByTagName('storybook-root')[0].innerHTML).toBe('👾: Fox');
120
123
  });
121
- it('should be re-rendered when template change', async () => {
124
+ (0, vitest_1.it)('should be re-rendered when template change', async () => {
122
125
  const render = await rendererFactory.getRendererInstance(rootTargetDOMNode);
123
126
  await render?.render({
124
127
  storyFnAngular: {
@@ -130,13 +133,13 @@ describe('RendererFactory', () => {
130
133
  forced: true,
131
134
  targetDOMNode: rootTargetDOMNode,
132
135
  });
133
- expect(document.body.getElementsByTagName('storybook-root')[0].innerHTML).toBe('🍺');
136
+ (0, vitest_1.expect)(document.body.getElementsByTagName('storybook-root')[0].innerHTML).toBe('🍺');
134
137
  });
135
138
  });
136
139
  });
137
- describe('DocsRenderer', () => {
138
- describe('when canvas render is done before', () => {
139
- beforeEach(async () => {
140
+ (0, vitest_1.describe)('DocsRenderer', () => {
141
+ (0, vitest_1.describe)('when canvas render is done before', () => {
142
+ (0, vitest_1.beforeEach)(async () => {
140
143
  // Init first Canvas render
141
144
  const render = await rendererFactory.getRendererInstance(rootTargetDOMNode);
142
145
  await render?.render({
@@ -147,18 +150,52 @@ describe('RendererFactory', () => {
147
150
  targetDOMNode: rootTargetDOMNode,
148
151
  });
149
152
  });
150
- it('should reset root HTML', async () => {
153
+ (0, vitest_1.it)('should reset root HTML', async () => {
151
154
  global.document
152
155
  .getElementById('storybook-root')
153
156
  .appendChild(global.document.createElement('👾'));
154
- expect(global.document.getElementById('storybook-root').innerHTML).toContain('Canvas 🖼');
157
+ (0, vitest_1.expect)(global.document.getElementById('storybook-root').innerHTML).toContain('Canvas 🖼');
155
158
  await rendererFactory.getRendererInstance(rootDocstargetDOMNode);
156
- expect(global.document.getElementById('storybook-root').innerHTML).toBe('');
159
+ (0, vitest_1.expect)(global.document.getElementById('storybook-root').innerHTML).toBe('');
157
160
  });
158
161
  });
159
- it('should get DocsRenderer instance', async () => {
162
+ (0, vitest_1.it)('should get DocsRenderer instance', async () => {
160
163
  const render = await rendererFactory.getRendererInstance(rootDocstargetDOMNode);
161
- expect(render).toBeInstanceOf(DocsRenderer_1.DocsRenderer);
164
+ (0, vitest_1.expect)(render).toBeInstanceOf(DocsRenderer_1.DocsRenderer);
165
+ });
166
+ (0, vitest_1.describe)('when multiple story for the same component', () => {
167
+ (0, vitest_1.it)('should render both stories', async () => {
168
+ let FooComponent = class FooComponent {
169
+ };
170
+ FooComponent = __decorate([
171
+ (0, core_1.Component)({ selector: 'foo', template: '🦊' })
172
+ ], FooComponent);
173
+ const render = await rendererFactory.getRendererInstance(global.document.getElementById('storybook-docs'));
174
+ const targetDOMNode1 = global.document.createElement('div');
175
+ targetDOMNode1.id = 'story-1';
176
+ global.document.getElementById('storybook-docs').appendChild(targetDOMNode1);
177
+ await render?.render({
178
+ storyFnAngular: {
179
+ props: {},
180
+ },
181
+ forced: false,
182
+ component: FooComponent,
183
+ targetDOMNode: targetDOMNode1,
184
+ });
185
+ const targetDOMNode2 = global.document.createElement('div');
186
+ targetDOMNode2.id = 'story-1';
187
+ global.document.getElementById('storybook-docs').appendChild(targetDOMNode2);
188
+ await render?.render({
189
+ storyFnAngular: {
190
+ props: {},
191
+ },
192
+ forced: false,
193
+ component: FooComponent,
194
+ targetDOMNode: targetDOMNode2,
195
+ });
196
+ (0, vitest_1.expect)(global.document.querySelectorAll('#story-1 > story-1')[0].innerHTML).toBe('<foo>🦊</foo><!--container-->');
197
+ (0, vitest_1.expect)(global.document.querySelectorAll('#story-1 > story-1')[1].innerHTML).toBe('<foo>🦊</foo><!--container-->');
198
+ });
162
199
  });
163
200
  });
164
201
  });
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const vitest_1 = require("vitest");
3
4
  const common_1 = require("@angular/common");
4
5
  const core_1 = require("@angular/core");
5
6
  const platform_browser_1 = require("@angular/platform-browser");
@@ -46,109 +47,109 @@ const extractApplicationProviders = (metadata, component) => {
46
47
  const { applicationProviders } = new PropertyExtractor_1.PropertyExtractor(metadata, component);
47
48
  return applicationProviders;
48
49
  };
49
- describe('PropertyExtractor', () => {
50
- jest.spyOn(console, 'warn').mockImplementation(() => { });
51
- describe('analyzeMetadata', () => {
52
- it('should remove BrowserModule', () => {
50
+ (0, vitest_1.describe)('PropertyExtractor', () => {
51
+ vitest_1.vi.spyOn(console, 'warn').mockImplementation(() => { });
52
+ (0, vitest_1.describe)('analyzeMetadata', () => {
53
+ (0, vitest_1.it)('should remove BrowserModule', () => {
53
54
  const metadata = {
54
55
  imports: [platform_browser_1.BrowserModule],
55
56
  };
56
57
  const { imports, providers, applicationProviders } = analyzeMetadata(metadata);
57
- expect(imports.flat(Number.MAX_VALUE)).toEqual([common_1.CommonModule]);
58
- expect(providers.flat(Number.MAX_VALUE)).toEqual([]);
59
- expect(applicationProviders.flat(Number.MAX_VALUE)).toEqual([]);
58
+ (0, vitest_1.expect)(imports.flat(Number.MAX_VALUE)).toEqual([common_1.CommonModule]);
59
+ (0, vitest_1.expect)(providers.flat(Number.MAX_VALUE)).toEqual([]);
60
+ (0, vitest_1.expect)(applicationProviders.flat(Number.MAX_VALUE)).toEqual([]);
60
61
  });
61
- it('should remove BrowserAnimationsModule and use its providers instead', () => {
62
+ (0, vitest_1.it)('should remove BrowserAnimationsModule and use its providers instead', () => {
62
63
  const metadata = {
63
64
  imports: [animations_1.BrowserAnimationsModule],
64
65
  };
65
66
  const { imports, providers, applicationProviders } = analyzeMetadata(metadata);
66
- expect(imports.flat(Number.MAX_VALUE)).toEqual([common_1.CommonModule]);
67
- expect(providers.flat(Number.MAX_VALUE)).toEqual([]);
68
- expect(applicationProviders.flat(Number.MAX_VALUE)).toEqual((0, animations_1.provideAnimations)());
67
+ (0, vitest_1.expect)(imports.flat(Number.MAX_VALUE)).toEqual([common_1.CommonModule]);
68
+ (0, vitest_1.expect)(providers.flat(Number.MAX_VALUE)).toEqual([]);
69
+ (0, vitest_1.expect)(applicationProviders.flat(Number.MAX_VALUE)).toEqual((0, animations_1.provideAnimations)());
69
70
  });
70
- it('should remove NoopAnimationsModule and use its providers instead', () => {
71
+ (0, vitest_1.it)('should remove NoopAnimationsModule and use its providers instead', () => {
71
72
  const metadata = {
72
73
  imports: [animations_1.NoopAnimationsModule],
73
74
  };
74
75
  const { imports, providers, applicationProviders } = analyzeMetadata(metadata);
75
- expect(imports.flat(Number.MAX_VALUE)).toEqual([common_1.CommonModule]);
76
- expect(providers.flat(Number.MAX_VALUE)).toEqual([]);
77
- expect(applicationProviders.flat(Number.MAX_VALUE)).toEqual((0, animations_1.provideNoopAnimations)());
76
+ (0, vitest_1.expect)(imports.flat(Number.MAX_VALUE)).toEqual([common_1.CommonModule]);
77
+ (0, vitest_1.expect)(providers.flat(Number.MAX_VALUE)).toEqual([]);
78
+ (0, vitest_1.expect)(applicationProviders.flat(Number.MAX_VALUE)).toEqual((0, animations_1.provideNoopAnimations)());
78
79
  });
79
- it('should remove Browser/Animations modules recursively', () => {
80
+ (0, vitest_1.it)('should remove Browser/Animations modules recursively', () => {
80
81
  const metadata = {
81
82
  imports: [animations_1.BrowserAnimationsModule, platform_browser_1.BrowserModule],
82
83
  };
83
84
  const { imports, providers, applicationProviders } = analyzeMetadata(metadata);
84
- expect(imports.flat(Number.MAX_VALUE)).toEqual([common_1.CommonModule]);
85
- expect(providers.flat(Number.MAX_VALUE)).toEqual([]);
86
- expect(applicationProviders.flat(Number.MAX_VALUE)).toEqual((0, animations_1.provideAnimations)());
85
+ (0, vitest_1.expect)(imports.flat(Number.MAX_VALUE)).toEqual([common_1.CommonModule]);
86
+ (0, vitest_1.expect)(providers.flat(Number.MAX_VALUE)).toEqual([]);
87
+ (0, vitest_1.expect)(applicationProviders.flat(Number.MAX_VALUE)).toEqual((0, animations_1.provideAnimations)());
87
88
  });
88
- it('should not destructure Angular official module', () => {
89
+ (0, vitest_1.it)('should not destructure Angular official module', () => {
89
90
  const metadata = {
90
91
  imports: [test_module_1.WithOfficialModule],
91
92
  };
92
93
  const { imports, providers, applicationProviders } = analyzeMetadata(metadata);
93
- expect(imports.flat(Number.MAX_VALUE)).toEqual([common_1.CommonModule, test_module_1.WithOfficialModule]);
94
- expect(providers.flat(Number.MAX_VALUE)).toEqual([]);
95
- expect(applicationProviders.flat(Number.MAX_VALUE)).toEqual([]);
94
+ (0, vitest_1.expect)(imports.flat(Number.MAX_VALUE)).toEqual([common_1.CommonModule, test_module_1.WithOfficialModule]);
95
+ (0, vitest_1.expect)(providers.flat(Number.MAX_VALUE)).toEqual([]);
96
+ (0, vitest_1.expect)(applicationProviders.flat(Number.MAX_VALUE)).toEqual([]);
96
97
  });
97
98
  });
98
- describe('extractImports', () => {
99
- it('should return Angular official modules', () => {
99
+ (0, vitest_1.describe)('extractImports', () => {
100
+ (0, vitest_1.it)('should return Angular official modules', () => {
100
101
  const imports = extractImports({ imports: [TestModuleWithImportsAndProviders] });
101
- expect(imports).toEqual([common_1.CommonModule, TestModuleWithImportsAndProviders]);
102
+ (0, vitest_1.expect)(imports).toEqual([common_1.CommonModule, TestModuleWithImportsAndProviders]);
102
103
  });
103
- it('should return standalone components', () => {
104
+ (0, vitest_1.it)('should return standalone components', () => {
104
105
  const imports = extractImports({
105
106
  imports: [TestModuleWithImportsAndProviders],
106
107
  }, StandaloneTestComponent);
107
- expect(imports).toEqual([
108
+ (0, vitest_1.expect)(imports).toEqual([
108
109
  common_1.CommonModule,
109
110
  TestModuleWithImportsAndProviders,
110
111
  StandaloneTestComponent,
111
112
  ]);
112
113
  });
113
- it('should return standalone directives', () => {
114
+ (0, vitest_1.it)('should return standalone directives', () => {
114
115
  const imports = extractImports({
115
116
  imports: [TestModuleWithImportsAndProviders],
116
117
  }, StandaloneTestDirective);
117
- expect(imports).toEqual([
118
+ (0, vitest_1.expect)(imports).toEqual([
118
119
  common_1.CommonModule,
119
120
  TestModuleWithImportsAndProviders,
120
121
  StandaloneTestDirective,
121
122
  ]);
122
123
  });
123
124
  });
124
- describe('extractDeclarations', () => {
125
- it('should return an array of declarations that contains `storyComponent`', () => {
125
+ (0, vitest_1.describe)('extractDeclarations', () => {
126
+ (0, vitest_1.it)('should return an array of declarations that contains `storyComponent`', () => {
126
127
  const declarations = extractDeclarations({ declarations: [TestComponent1] }, TestComponent2);
127
- expect(declarations).toEqual([TestComponent1, TestComponent2]);
128
+ (0, vitest_1.expect)(declarations).toEqual([TestComponent1, TestComponent2]);
128
129
  });
129
130
  });
130
- describe('analyzeDecorators', () => {
131
- it('isStandalone should be false', () => {
131
+ (0, vitest_1.describe)('analyzeDecorators', () => {
132
+ (0, vitest_1.it)('isStandalone should be false', () => {
132
133
  const { isStandalone } = PropertyExtractor_1.PropertyExtractor.analyzeDecorators(TestComponent1);
133
- expect(isStandalone).toBe(false);
134
+ (0, vitest_1.expect)(isStandalone).toBe(false);
134
135
  });
135
- it('isStandalone should be true', () => {
136
+ (0, vitest_1.it)('isStandalone should be true', () => {
136
137
  const { isStandalone } = PropertyExtractor_1.PropertyExtractor.analyzeDecorators(StandaloneTestComponent);
137
- expect(isStandalone).toBe(true);
138
+ (0, vitest_1.expect)(isStandalone).toBe(true);
138
139
  });
139
140
  });
140
- describe('extractProviders', () => {
141
- it('should return an array of providers', () => {
141
+ (0, vitest_1.describe)('extractProviders', () => {
142
+ (0, vitest_1.it)('should return an array of providers', () => {
142
143
  const providers = extractProviders({
143
144
  providers: [TestService],
144
145
  });
145
- expect(providers).toEqual([TestService]);
146
+ (0, vitest_1.expect)(providers).toEqual([TestService]);
146
147
  });
147
- it('should return an array of singletons extracted', () => {
148
+ (0, vitest_1.it)('should return an array of singletons extracted', () => {
148
149
  const singeltons = extractApplicationProviders({
149
150
  imports: [animations_1.BrowserAnimationsModule],
150
151
  });
151
- expect(singeltons).toEqual((0, animations_1.provideAnimations)());
152
+ (0, vitest_1.expect)(singeltons).toEqual((0, animations_1.provideAnimations)());
152
153
  });
153
154
  });
154
155
  });
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Increments the count for a storyId and returns the next UID.
3
+ *
4
+ * When a story is bootstrapped, the storyId is used as the element tag. That
5
+ * becomes an issue when a story is rendered multiple times in the same docs
6
+ * page. This function returns a UID that is appended to the storyId to make
7
+ * it unique.
8
+ *
9
+ * @param storyId id of a story
10
+ * @returns uid of a story
11
+ */
12
+ export declare const getNextStoryUID: (storyId: string) => string;
13
+ /**
14
+ * Clears the storyId counts.
15
+ *
16
+ * Can be useful for testing, where you need predictable increments, without
17
+ * reloading the global state.
18
+ *
19
+ * If onlyStoryId is provided, only that storyId is cleared.
20
+ *
21
+ * @param onlyStoryId id of a story
22
+ */
23
+ export declare const clearStoryUIDs: (onlyStoryId?: string) => void;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.clearStoryUIDs = exports.getNextStoryUID = void 0;
4
+ /**
5
+ * Count of stories for each storyId.
6
+ */
7
+ const storyCounts = new Map();
8
+ /**
9
+ * Increments the count for a storyId and returns the next UID.
10
+ *
11
+ * When a story is bootstrapped, the storyId is used as the element tag. That
12
+ * becomes an issue when a story is rendered multiple times in the same docs
13
+ * page. This function returns a UID that is appended to the storyId to make
14
+ * it unique.
15
+ *
16
+ * @param storyId id of a story
17
+ * @returns uid of a story
18
+ */
19
+ const getNextStoryUID = (storyId) => {
20
+ if (!storyCounts.has(storyId)) {
21
+ storyCounts.set(storyId, -1);
22
+ }
23
+ const count = storyCounts.get(storyId) + 1;
24
+ storyCounts.set(storyId, count);
25
+ return `${storyId}-${count}`;
26
+ };
27
+ exports.getNextStoryUID = getNextStoryUID;
28
+ /**
29
+ * Clears the storyId counts.
30
+ *
31
+ * Can be useful for testing, where you need predictable increments, without
32
+ * reloading the global state.
33
+ *
34
+ * If onlyStoryId is provided, only that storyId is cleared.
35
+ *
36
+ * @param onlyStoryId id of a story
37
+ */
38
+ const clearStoryUIDs = (onlyStoryId) => {
39
+ if (onlyStoryId !== undefined && onlyStoryId !== null) {
40
+ storyCounts.delete(onlyStoryId);
41
+ }
42
+ else {
43
+ storyCounts.clear();
44
+ }
45
+ };
46
+ exports.clearStoryUIDs = clearStoryUIDs;
@@ -6,6 +6,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
6
6
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7
7
  };
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
+ const vitest_1 = require("vitest");
9
10
  const core_1 = require("@angular/core");
10
11
  const decorators_1 = require("./decorators");
11
12
  const defaultContext = {
@@ -23,7 +24,7 @@ const defaultContext = {
23
24
  globals: {},
24
25
  hooks: {},
25
26
  loaded: {},
26
- originalStoryFn: jest.fn(),
27
+ originalStoryFn: vitest_1.vi.fn(),
27
28
  viewMode: 'story',
28
29
  abortSignal: undefined,
29
30
  canvasElement: undefined,
@@ -39,11 +40,11 @@ let MockComponent = class MockComponent {
39
40
  MockComponent = __decorate([
40
41
  (0, core_1.Component)({})
41
42
  ], MockComponent);
42
- describe('applicationConfig', () => {
43
+ (0, vitest_1.describe)('applicationConfig', () => {
43
44
  const provider1 = () => { };
44
45
  const provider2 = () => { };
45
- it('should apply global config', () => {
46
- expect((0, decorators_1.applicationConfig)({
46
+ (0, vitest_1.it)('should apply global config', () => {
47
+ (0, vitest_1.expect)((0, decorators_1.applicationConfig)({
47
48
  providers: [provider1],
48
49
  })(() => ({}), defaultContext)).toEqual({
49
50
  applicationConfig: {
@@ -51,8 +52,8 @@ describe('applicationConfig', () => {
51
52
  },
52
53
  });
53
54
  });
54
- it('should apply story config', () => {
55
- expect((0, decorators_1.applicationConfig)({
55
+ (0, vitest_1.it)('should apply story config', () => {
56
+ (0, vitest_1.expect)((0, decorators_1.applicationConfig)({
56
57
  providers: [],
57
58
  })(() => ({
58
59
  applicationConfig: {
@@ -66,8 +67,8 @@ describe('applicationConfig', () => {
66
67
  },
67
68
  });
68
69
  });
69
- it('should merge global and story config', () => {
70
- expect((0, decorators_1.applicationConfig)({
70
+ (0, vitest_1.it)('should merge global and story config', () => {
71
+ (0, vitest_1.expect)((0, decorators_1.applicationConfig)({
71
72
  providers: [provider1],
72
73
  })(() => ({
73
74
  applicationConfig: {
@@ -82,15 +83,15 @@ describe('applicationConfig', () => {
82
83
  });
83
84
  });
84
85
  });
85
- describe('moduleMetadata', () => {
86
- it('should add metadata to a story without it', () => {
86
+ (0, vitest_1.describe)('moduleMetadata', () => {
87
+ (0, vitest_1.it)('should add metadata to a story without it', () => {
87
88
  const result = (0, decorators_1.moduleMetadata)({
88
89
  imports: [MockModule],
89
90
  providers: [MockService],
90
91
  })(() => ({}),
91
92
  // deepscan-disable-next-line
92
93
  defaultContext);
93
- expect(result).toEqual({
94
+ (0, vitest_1.expect)(result).toEqual({
94
95
  moduleMetadata: {
95
96
  declarations: [],
96
97
  entryComponents: [],
@@ -100,7 +101,7 @@ describe('moduleMetadata', () => {
100
101
  },
101
102
  });
102
103
  });
103
- it('should combine with individual metadata on a story', () => {
104
+ (0, vitest_1.it)('should combine with individual metadata on a story', () => {
104
105
  const result = (0, decorators_1.moduleMetadata)({
105
106
  imports: [MockModule],
106
107
  })(() => ({
@@ -112,7 +113,7 @@ describe('moduleMetadata', () => {
112
113
  }),
113
114
  // deepscan-disable-next-line
114
115
  defaultContext);
115
- expect(result).toEqual({
116
+ (0, vitest_1.expect)(result).toEqual({
116
117
  component: MockComponent,
117
118
  moduleMetadata: {
118
119
  declarations: [],
@@ -123,7 +124,7 @@ describe('moduleMetadata', () => {
123
124
  },
124
125
  });
125
126
  });
126
- it('should return the original metadata if passed null', () => {
127
+ (0, vitest_1.it)('should return the original metadata if passed null', () => {
127
128
  const result = (0, decorators_1.moduleMetadata)(null)(() => ({
128
129
  component: MockComponent,
129
130
  moduleMetadata: {
@@ -132,7 +133,7 @@ describe('moduleMetadata', () => {
132
133
  }),
133
134
  // deepscan-disable-next-line
134
135
  defaultContext);
135
- expect(result).toEqual({
136
+ (0, vitest_1.expect)(result).toEqual({
136
137
  component: MockComponent,
137
138
  moduleMetadata: {
138
139
  declarations: [],
@@ -1 +1 @@
1
- import 'jest-specific-snapshot';
1
+ export {};
@@ -3,7 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- require("jest-specific-snapshot");
7
6
  const path_1 = __importDefault(require("path"));
8
7
  const fs_1 = __importDefault(require("fs"));
9
8
  const tmp_1 = __importDefault(require("tmp"));
@@ -48,13 +47,13 @@ describe('angular component properties', () => {
48
47
  // // snapshot the output of compodoc
49
48
  // const compodocOutput = runCompodoc(inputPath);
50
49
  // const compodocJson = JSON.parse(compodocOutput);
51
- // expect(compodocJson).toMatchSpecificSnapshot(
50
+ // expect(compodocJson).toMatchFileSnapshot(
52
51
  // path.join(testDir, `compodoc-${SNAPSHOT_OS}.snapshot`)
53
52
  // );
54
53
  // // snapshot the output of addon-docs angular-properties
55
54
  // const componentData = findComponentByName('InputComponent', compodocJson);
56
55
  // const argTypes = extractArgTypesFromData(componentData);
57
- // expect(argTypes).toMatchSpecificSnapshot(path.join(testDir, 'argtypes.snapshot'));
56
+ // expect(argTypes).toMatchFileSnapshot(path.join(testDir, 'argtypes.snapshot'));
58
57
  // });
59
58
  }
60
59
  }
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const vitest_1 = require("vitest");
3
4
  const compodoc_1 = require("./compodoc");
4
5
  const makeProperty = (compodocType) => ({
5
6
  type: compodocType,
@@ -93,10 +94,10 @@ const getDummyCompodocJson = () => {
93
94
  },
94
95
  };
95
96
  };
96
- describe('extractType', () => {
97
- describe('with compodoc type', () => {
97
+ (0, vitest_1.describe)('extractType', () => {
98
+ (0, vitest_1.describe)('with compodoc type', () => {
98
99
  (0, compodoc_1.setCompodocJson)(getDummyCompodocJson());
99
- it.each([
100
+ vitest_1.it.each([
100
101
  ['string', { name: 'string' }],
101
102
  ['boolean', { name: 'boolean' }],
102
103
  ['number', { name: 'number' }],
@@ -112,11 +113,11 @@ describe('extractType', () => {
112
113
  // ['EnumNumericInitial', { name: 'other', value: 'empty-enum' }], // seems to be wrong | TODO: REVISIT
113
114
  ['EnumStringValues', { name: 'enum', value: ['PRIMARY', 'SECONDARY', 'TERTIARY'] }],
114
115
  ])('%s', (compodocType, expected) => {
115
- expect((0, compodoc_1.extractType)(makeProperty(compodocType), null)).toEqual(expected);
116
+ (0, vitest_1.expect)((0, compodoc_1.extractType)(makeProperty(compodocType), null)).toEqual(expected);
116
117
  });
117
118
  });
118
- describe('without compodoc type', () => {
119
- it.each([
119
+ (0, vitest_1.describe)('without compodoc type', () => {
120
+ vitest_1.it.each([
120
121
  ['string', { name: 'string' }],
121
122
  ['', { name: 'string' }],
122
123
  [false, { name: 'boolean' }],
@@ -125,7 +126,7 @@ describe('extractType', () => {
125
126
  // [{ foo: 1 }, { name: 'other', value: 'empty-enum' }], // seems to be wrong | TODO: REVISIT
126
127
  [undefined, { name: 'other', value: 'void' }],
127
128
  ])('%s', (defaultValue, expected) => {
128
- expect((0, compodoc_1.extractType)(makeProperty(null), defaultValue)).toEqual(expected);
129
+ (0, vitest_1.expect)((0, compodoc_1.extractType)(makeProperty(null), defaultValue)).toEqual(expected);
129
130
  });
130
131
  });
131
132
  });
@@ -0,0 +1 @@
1
+ import '@analogjs/vite-plugin-angular/setup-vitest';
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ // eslint-disable-next-line import/no-extraneous-dependencies
4
+ require("@analogjs/vite-plugin-angular/setup-vitest");
5
+ const testing_1 = require("@angular/platform-browser-dynamic/testing");
6
+ const testing_2 = require("@angular/core/testing");
7
+ (0, testing_2.getTestBed)().initTestEnvironment(testing_1.BrowserDynamicTestingModule, (0, testing_1.platformBrowserDynamicTesting)());
@@ -0,0 +1,5 @@
1
+ // eslint-disable-next-line import/no-extraneous-dependencies
2
+ import '@analogjs/vite-plugin-angular/setup-vitest';
3
+ import { BrowserDynamicTestingModule, platformBrowserDynamicTesting, } from '@angular/platform-browser-dynamic/testing';
4
+ import { getTestBed } from '@angular/core/testing';
5
+ getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting());