Skip to content

Commit c8df5d1

Browse files
committed
refactor: migrate apps/meteor/.storybook/mocks/meteor.js to TypeScript
1 parent 4638c2d commit c8df5d1

File tree

3 files changed

+97
-97
lines changed

3 files changed

+97
-97
lines changed

apps/meteor/.storybook/main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { StorybookConfig } from '@storybook/react-webpack5';
44
import webpack from 'webpack';
55

66
export default {
7-
stories: ['../client/**/*.stories.{js,tsx}', '../app/**/*.stories.{js,tsx}', '../ee/app/**/*.stories.{js,tsx}'],
7+
stories: ['../client/**/*.stories.{js,tsx}'],
88

99
addons: [
1010
getAbsolutePath('@storybook/addon-essentials'),
@@ -44,7 +44,7 @@ export default {
4444
});
4545

4646
config.plugins?.push(
47-
new webpack.NormalModuleReplacementPlugin(/^meteor/, require.resolve('./mocks/meteor.js')),
47+
new webpack.NormalModuleReplacementPlugin(/^meteor/, require.resolve('./mocks/meteor.ts')),
4848
new webpack.NormalModuleReplacementPlugin(/(app)\/*.*\/(server)\/*/, require.resolve('./mocks/empty.ts')),
4949
);
5050

apps/meteor/.storybook/mocks/meteor.js

Lines changed: 0 additions & 95 deletions
This file was deleted.
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
export const Meteor = {
2+
Device: {
3+
isDesktop: () => false,
4+
},
5+
isClient: true,
6+
isServer: false,
7+
_localStorage: window.localStorage,
8+
absoluteUrl: Object.assign(() => undefined, {
9+
defaultOptions: {},
10+
}),
11+
userId: () => undefined,
12+
Streamer: () => ({
13+
on: () => undefined,
14+
removeListener: () => undefined,
15+
}),
16+
StreamerCentral: {
17+
on: () => undefined,
18+
removeListener: () => undefined,
19+
},
20+
startup: () => undefined,
21+
methods: () => undefined,
22+
call: () => undefined,
23+
connection: {
24+
_stream: {
25+
on: () => undefined,
26+
},
27+
},
28+
users: {},
29+
};
30+
31+
export const Tracker = {
32+
autorun: () => ({
33+
stop: () => undefined,
34+
}),
35+
nonreactive: (fn: () => void) => fn(),
36+
Dependency: () => undefined,
37+
};
38+
39+
export const Accounts = {
40+
onLogin: () => undefined,
41+
onLogout: () => undefined,
42+
};
43+
44+
export const Mongo = {
45+
Collection: () => ({
46+
find: () => ({
47+
observe: () => undefined,
48+
fetch: () => [],
49+
}),
50+
}),
51+
};
52+
53+
export const ReactiveVar = <T>(val: T) => {
54+
let currentVal = val;
55+
return {
56+
get: () => currentVal,
57+
set: (val: T) => {
58+
currentVal = val;
59+
},
60+
};
61+
};
62+
63+
export const ReactiveDict = () => ({
64+
get: () => undefined,
65+
set: () => undefined,
66+
all: () => undefined,
67+
});
68+
69+
export const Template = Object.assign(
70+
() => ({
71+
onCreated: () => undefined,
72+
onRendered: () => undefined,
73+
onDestroyed: () => undefined,
74+
helpers: () => undefined,
75+
events: () => undefined,
76+
}),
77+
{
78+
registerHelper: () => undefined,
79+
__checkName: () => undefined,
80+
},
81+
);
82+
83+
export const check = () => undefined;
84+
85+
export const FlowRouter = {
86+
route: () => undefined,
87+
group: () => ({
88+
route: () => undefined,
89+
}),
90+
};
91+
92+
export const Session = {
93+
get: () => undefined,
94+
set: () => undefined,
95+
};

0 commit comments

Comments
 (0)