@idealyst/cli 1.2.0 → 1.2.3
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/dist/commands/add.js +233 -0
- package/dist/commands/add.js.map +1 -0
- package/dist/commands/index.js +13 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/info.js +193 -0
- package/dist/commands/info.js.map +1 -0
- package/dist/commands/init.js +155 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/constants.js +125 -0
- package/dist/constants.js.map +1 -0
- package/dist/generators/core/index.js +23 -0
- package/dist/generators/core/index.js.map +1 -0
- package/dist/generators/core/mobile.js +251 -0
- package/dist/generators/core/mobile.js.map +1 -0
- package/dist/generators/core/shared.js +474 -0
- package/dist/generators/core/shared.js.map +1 -0
- package/dist/generators/core/web.js +330 -0
- package/dist/generators/core/web.js.map +1 -0
- package/dist/generators/extensions/api.js +223 -0
- package/dist/generators/extensions/api.js.map +1 -0
- package/dist/generators/extensions/devcontainer.js +575 -0
- package/dist/generators/extensions/devcontainer.js.map +1 -0
- package/dist/generators/extensions/graphql.js +202 -0
- package/dist/generators/extensions/graphql.js.map +1 -0
- package/dist/generators/extensions/index.js +17 -0
- package/dist/generators/extensions/index.js.map +1 -0
- package/dist/generators/extensions/prisma.js +249 -0
- package/dist/generators/extensions/prisma.js.map +1 -0
- package/dist/generators/extensions/trpc.js +258 -0
- package/dist/generators/extensions/trpc.js.map +1 -0
- package/dist/generators/index.js +122 -4
- package/dist/generators/index.js.map +1 -1
- package/dist/generators/reactNative.js +253 -0
- package/dist/generators/reactNative.js.map +1 -0
- package/dist/generators/workspace.js +303 -0
- package/dist/generators/workspace.js.map +1 -0
- package/dist/identifiers/android.js +75 -0
- package/dist/identifiers/android.js.map +1 -0
- package/dist/identifiers/index.js +35 -0
- package/dist/identifiers/index.js.map +1 -0
- package/dist/identifiers/ios.js +65 -0
- package/dist/identifiers/ios.js.map +1 -0
- package/dist/index.js +41 -319
- package/dist/index.js.map +1 -1
- package/dist/templates/copier.js +135 -0
- package/dist/templates/copier.js.map +1 -0
- package/dist/templates/index.js +23 -0
- package/dist/templates/index.js.map +1 -0
- package/dist/templates/merger.js +113 -0
- package/dist/templates/merger.js.map +1 -0
- package/dist/templates/processor.js +142 -0
- package/dist/templates/processor.js.map +1 -0
- package/dist/types/commands/add.d.ts +14 -0
- package/dist/types/commands/index.d.ts +6 -0
- package/dist/types/commands/info.d.ts +10 -0
- package/dist/types/commands/init.d.ts +19 -0
- package/dist/types/constants.d.ts +82 -0
- package/dist/types/generators/core/index.d.ts +6 -0
- package/dist/types/generators/core/mobile.d.ts +14 -0
- package/dist/types/generators/core/shared.d.ts +8 -0
- package/dist/types/generators/core/web.d.ts +8 -0
- package/dist/types/generators/extensions/api.d.ts +8 -0
- package/dist/types/generators/extensions/devcontainer.d.ts +15 -0
- package/dist/types/generators/extensions/graphql.d.ts +8 -0
- package/dist/types/generators/extensions/index.d.ts +8 -0
- package/dist/types/generators/extensions/prisma.d.ts +8 -0
- package/dist/types/generators/extensions/trpc.d.ts +9 -0
- package/dist/types/generators/index.d.ts +11 -3
- package/dist/types/generators/reactNative.d.ts +19 -0
- package/dist/types/generators/workspace.d.ts +8 -0
- package/dist/types/identifiers/android.d.ts +26 -0
- package/dist/types/identifiers/index.d.ts +26 -0
- package/dist/types/identifiers/ios.d.ts +21 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/templates/copier.d.ts +24 -0
- package/dist/types/templates/index.d.ts +6 -0
- package/dist/types/templates/merger.d.ts +43 -0
- package/dist/types/templates/processor.d.ts +39 -0
- package/dist/types/types.d.ts +184 -5
- package/dist/types/utils/filesystem.d.ts +56 -0
- package/dist/types/utils/index.d.ts +7 -0
- package/dist/types/utils/logger.d.ts +64 -0
- package/dist/types/utils/shell.d.ts +35 -0
- package/dist/types/utils/validation.d.ts +32 -0
- package/dist/types/wizard/index.d.ts +20 -0
- package/dist/types/wizard/steps/apiExtension.d.ts +5 -0
- package/dist/types/wizard/steps/appDisplayName.d.ts +5 -0
- package/dist/types/wizard/steps/devcontainerExtension.d.ts +5 -0
- package/dist/types/wizard/steps/graphqlExtension.d.ts +5 -0
- package/dist/types/wizard/steps/index.d.ts +12 -0
- package/dist/types/wizard/steps/orgDomain.d.ts +5 -0
- package/dist/types/wizard/steps/prismaExtension.d.ts +5 -0
- package/dist/types/wizard/steps/projectName.d.ts +5 -0
- package/dist/types/wizard/steps/summary.d.ts +5 -0
- package/dist/types/wizard/steps/trpcExtension.d.ts +5 -0
- package/dist/types/wizard/validators.d.ts +17 -0
- package/dist/types.js +74 -0
- package/dist/types.js.map +1 -1
- package/dist/utils/filesystem.js +173 -0
- package/dist/utils/filesystem.js.map +1 -0
- package/dist/utils/index.js +24 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/logger.js +106 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/shell.js +113 -0
- package/dist/utils/shell.js.map +1 -0
- package/dist/utils/validation.js +196 -0
- package/dist/utils/validation.js.map +1 -0
- package/dist/wizard/index.js +177 -0
- package/dist/wizard/index.js.map +1 -0
- package/dist/wizard/steps/apiExtension.js +33 -0
- package/dist/wizard/steps/apiExtension.js.map +1 -0
- package/dist/wizard/steps/appDisplayName.js +53 -0
- package/dist/wizard/steps/appDisplayName.js.map +1 -0
- package/dist/wizard/steps/devcontainerExtension.js +131 -0
- package/dist/wizard/steps/devcontainerExtension.js.map +1 -0
- package/dist/wizard/steps/graphqlExtension.js +37 -0
- package/dist/wizard/steps/graphqlExtension.js.map +1 -0
- package/dist/wizard/steps/index.js +25 -0
- package/dist/wizard/steps/index.js.map +1 -0
- package/dist/wizard/steps/orgDomain.js +40 -0
- package/dist/wizard/steps/orgDomain.js.map +1 -0
- package/dist/wizard/steps/prismaExtension.js +33 -0
- package/dist/wizard/steps/prismaExtension.js.map +1 -0
- package/dist/wizard/steps/projectName.js +40 -0
- package/dist/wizard/steps/projectName.js.map +1 -0
- package/dist/wizard/steps/summary.js +119 -0
- package/dist/wizard/steps/summary.js.map +1 -0
- package/dist/wizard/steps/trpcExtension.js +37 -0
- package/dist/wizard/steps/trpcExtension.js.map +1 -0
- package/dist/wizard/validators.js +35 -0
- package/dist/wizard/validators.js.map +1 -0
- package/package.json +6 -19
- package/README.md +0 -110
- package/dist/generators/init.js +0 -268
- package/dist/generators/init.js.map +0 -1
- package/dist/generators/utils.js +0 -682
- package/dist/generators/utils.js.map +0 -1
- package/dist/scripts/configure-react-native-monorepo.js +0 -144
- package/dist/scripts/configure-react-native-monorepo.js.map +0 -1
- package/dist/template/.devcontainer/Dockerfile +0 -26
- package/dist/template/.devcontainer/devcontainer.json +0 -113
- package/dist/template/.devcontainer/docker-compose.yml +0 -59
- package/dist/template/.devcontainer/figma-mcp.sh +0 -32
- package/dist/template/.devcontainer/gitignore.template +0 -2
- package/dist/template/.devcontainer/setup.sh +0 -45
- package/dist/template/DOCKER.md +0 -0
- package/dist/template/Dockerfile +0 -111
- package/dist/template/README.md +0 -233
- package/dist/template/docker/nginx/prod.conf +0 -238
- package/dist/template/docker/nginx.conf +0 -131
- package/dist/template/docker/postgres/init.sql +0 -41
- package/dist/template/docker/prometheus/prometheus.yml +0 -52
- package/dist/template/docker-compose.prod.yml +0 -146
- package/dist/template/docker-compose.yml +0 -143
- package/dist/template/dockerignore.template +0 -151
- package/dist/template/env.example.template +0 -36
- package/dist/template/gitignore.template +0 -56
- package/dist/template/jest.config.js +0 -20
- package/dist/template/mcp.json.template +0 -8
- package/dist/template/package.json +0 -45
- package/dist/template/packages/api/README.md +0 -510
- package/dist/template/packages/api/__tests__/api.test.ts +0 -26
- package/dist/template/packages/api/env.example.template +0 -6
- package/dist/template/packages/api/gitignore.template +0 -35
- package/dist/template/packages/api/jest.config.js +0 -23
- package/dist/template/packages/api/jest.setup.js +0 -9
- package/dist/template/packages/api/package.json +0 -66
- package/dist/template/packages/api/src/context.ts +0 -52
- package/dist/template/packages/api/src/controllers/TestController.ts +0 -0
- package/dist/template/packages/api/src/graphql/builder.ts +0 -75
- package/dist/template/packages/api/src/graphql/generated.ts +0 -64
- package/dist/template/packages/api/src/graphql/index.ts +0 -75
- package/dist/template/packages/api/src/graphql/types/index.ts +0 -44
- package/dist/template/packages/api/src/graphql/types/test.ts +0 -245
- package/dist/template/packages/api/src/index.ts +0 -26
- package/dist/template/packages/api/src/lib/database.ts +0 -23
- package/dist/template/packages/api/src/router/index.ts +0 -163
- package/dist/template/packages/api/src/routers/test.ts +0 -161
- package/dist/template/packages/api/src/server.ts +0 -68
- package/dist/template/packages/api/src/trpc.ts +0 -28
- package/dist/template/packages/api/tsconfig.json +0 -44
- package/dist/template/packages/database/README.md +0 -162
- package/dist/template/packages/database/gitignore.template +0 -41
- package/dist/template/packages/database/package.json +0 -49
- package/dist/template/packages/database/prisma/seed.ts +0 -64
- package/dist/template/packages/database/schema.prisma +0 -107
- package/dist/template/packages/database/src/index.ts +0 -15
- package/dist/template/packages/database/src/validators.ts +0 -10
- package/dist/template/packages/database/tsconfig.json +0 -18
- package/dist/template/packages/mobile/README.md +0 -86
- package/dist/template/packages/mobile/__tests__/App.test.tsx +0 -156
- package/dist/template/packages/mobile/__tests__/components.test.tsx +0 -300
- package/dist/template/packages/mobile/app.json +0 -5
- package/dist/template/packages/mobile/babel.config.js +0 -10
- package/dist/template/packages/mobile/gitignore.template +0 -73
- package/dist/template/packages/mobile/index.js +0 -6
- package/dist/template/packages/mobile/jest.config.js +0 -21
- package/dist/template/packages/mobile/jest.setup.js +0 -12
- package/dist/template/packages/mobile/metro.config.js +0 -36
- package/dist/template/packages/mobile/package.json +0 -60
- package/dist/template/packages/mobile/src/App.tsx +0 -8
- package/dist/template/packages/mobile/src/utils/trpc.ts +0 -7
- package/dist/template/packages/mobile/tsconfig.json +0 -28
- package/dist/template/packages/shared/README.md +0 -135
- package/dist/template/packages/shared/__tests__/shared.test.ts +0 -51
- package/dist/template/packages/shared/gitignore.template +0 -35
- package/dist/template/packages/shared/jest.config.js +0 -22
- package/dist/template/packages/shared/package.json +0 -68
- package/dist/template/packages/shared/src/components/App.tsx +0 -57
- package/dist/template/packages/shared/src/components/HelloWorld.tsx +0 -531
- package/dist/template/packages/shared/src/components/index.ts +0 -1
- package/dist/template/packages/shared/src/graphql/client.ts +0 -34
- package/dist/template/packages/shared/src/index.ts +0 -22
- package/dist/template/packages/shared/src/navigation/AppRouter.tsx +0 -565
- package/dist/template/packages/shared/src/trpc/client.ts +0 -44
- package/dist/template/packages/shared/tsconfig.json +0 -22
- package/dist/template/packages/web/README.md +0 -131
- package/dist/template/packages/web/__tests__/App.test.tsx +0 -342
- package/dist/template/packages/web/__tests__/components.test.tsx +0 -564
- package/dist/template/packages/web/gitignore.template +0 -35
- package/dist/template/packages/web/index.html +0 -13
- package/dist/template/packages/web/jest.config.js +0 -27
- package/dist/template/packages/web/jest.setup.js +0 -24
- package/dist/template/packages/web/package.json +0 -69
- package/dist/template/packages/web/src/App.tsx +0 -14
- package/dist/template/packages/web/src/components/TestDemo.tsx +0 -164
- package/dist/template/packages/web/src/main.tsx +0 -25
- package/dist/template/packages/web/src/utils/trpc.ts +0 -7
- package/dist/template/packages/web/tsconfig.json +0 -26
- package/dist/template/packages/web/vite.config.ts +0 -98
- package/dist/template/setup.sh +0 -30
- package/dist/template/tsconfig.json +0 -22
- package/dist/template/yarnrc.yml.template +0 -4
- package/dist/types/generators/init.d.ts +0 -5
- package/dist/types/generators/utils.d.ts +0 -45
- package/dist/types/scripts/configure-react-native-monorepo.d.ts +0 -23
- package/template/.devcontainer/Dockerfile +0 -26
- package/template/.devcontainer/devcontainer.json +0 -113
- package/template/.devcontainer/docker-compose.yml +0 -59
- package/template/.devcontainer/figma-mcp.sh +0 -32
- package/template/.devcontainer/setup.sh +0 -45
- package/template/.dockerignore +0 -151
- package/template/.env.example +0 -36
- package/template/.env.production +0 -56
- package/template/DOCKER.md +0 -0
- package/template/Dockerfile +0 -111
- package/template/README.md +0 -233
- package/template/docker/nginx/prod.conf +0 -238
- package/template/docker/nginx.conf +0 -131
- package/template/docker/postgres/init.sql +0 -41
- package/template/docker/prometheus/prometheus.yml +0 -52
- package/template/docker-compose.prod.yml +0 -146
- package/template/docker-compose.yml +0 -143
- package/template/jest.config.js +0 -20
- package/template/package.json +0 -45
- package/template/packages/api/.env.example +0 -6
- package/template/packages/api/README.md +0 -510
- package/template/packages/api/__tests__/api.test.ts +0 -26
- package/template/packages/api/jest.config.js +0 -23
- package/template/packages/api/jest.setup.js +0 -9
- package/template/packages/api/package.json +0 -66
- package/template/packages/api/src/context.ts +0 -52
- package/template/packages/api/src/controllers/TestController.ts +0 -0
- package/template/packages/api/src/graphql/builder.ts +0 -75
- package/template/packages/api/src/graphql/generated.ts +0 -64
- package/template/packages/api/src/graphql/index.ts +0 -75
- package/template/packages/api/src/graphql/types/index.ts +0 -44
- package/template/packages/api/src/graphql/types/test.ts +0 -245
- package/template/packages/api/src/index.ts +0 -26
- package/template/packages/api/src/lib/database.ts +0 -23
- package/template/packages/api/src/router/index.ts +0 -163
- package/template/packages/api/src/routers/test.ts +0 -161
- package/template/packages/api/src/server.ts +0 -68
- package/template/packages/api/src/trpc.ts +0 -28
- package/template/packages/api/tsconfig.json +0 -44
- package/template/packages/database/README.md +0 -162
- package/template/packages/database/package.json +0 -49
- package/template/packages/database/prisma/seed.ts +0 -64
- package/template/packages/database/schema.prisma +0 -107
- package/template/packages/database/src/index.ts +0 -15
- package/template/packages/database/src/validators.ts +0 -10
- package/template/packages/database/tsconfig.json +0 -18
- package/template/packages/mobile/README.md +0 -86
- package/template/packages/mobile/__tests__/App.test.tsx +0 -156
- package/template/packages/mobile/__tests__/components.test.tsx +0 -300
- package/template/packages/mobile/app.json +0 -5
- package/template/packages/mobile/babel.config.js +0 -26
- package/template/packages/mobile/index.js +0 -8
- package/template/packages/mobile/jest.config.js +0 -21
- package/template/packages/mobile/jest.setup.js +0 -12
- package/template/packages/mobile/metro.config.js +0 -36
- package/template/packages/mobile/package.json +0 -60
- package/template/packages/mobile/src/App.tsx +0 -8
- package/template/packages/mobile/src/utils/trpc.ts +0 -7
- package/template/packages/mobile/tsconfig.json +0 -28
- package/template/packages/shared/README.md +0 -135
- package/template/packages/shared/__tests__/shared.test.ts +0 -51
- package/template/packages/shared/jest.config.js +0 -22
- package/template/packages/shared/package.json +0 -68
- package/template/packages/shared/src/components/App.tsx +0 -57
- package/template/packages/shared/src/components/HelloWorld.tsx +0 -531
- package/template/packages/shared/src/components/index.ts +0 -1
- package/template/packages/shared/src/graphql/client.ts +0 -34
- package/template/packages/shared/src/index.ts +0 -25
- package/template/packages/shared/src/navigation/AppRouter.tsx +0 -565
- package/template/packages/shared/src/trpc/client.ts +0 -44
- package/template/packages/shared/src/unistyles.ts +0 -50
- package/template/packages/shared/tsconfig.json +0 -22
- package/template/packages/web/README.md +0 -131
- package/template/packages/web/__tests__/App.test.tsx +0 -342
- package/template/packages/web/__tests__/components.test.tsx +0 -564
- package/template/packages/web/index.html +0 -13
- package/template/packages/web/jest.config.js +0 -27
- package/template/packages/web/jest.setup.js +0 -24
- package/template/packages/web/package.json +0 -69
- package/template/packages/web/src/App.tsx +0 -14
- package/template/packages/web/src/components/TestDemo.tsx +0 -164
- package/template/packages/web/src/main.tsx +0 -27
- package/template/packages/web/src/utils/trpc.ts +0 -7
- package/template/packages/web/tsconfig.json +0 -26
- package/template/packages/web/vite.config.ts +0 -114
- package/template/setup.sh +0 -30
- package/template/tsconfig.json +0 -22
|
@@ -1,300 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Example component tests for React Native
|
|
3
|
-
* @format
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import React from 'react';
|
|
7
|
-
import ReactTestRenderer from 'react-test-renderer';
|
|
8
|
-
|
|
9
|
-
describe('React Native Component Testing Examples', () => {
|
|
10
|
-
// Example 1: Simple Text Component
|
|
11
|
-
const SimpleText = ({ text, color = 'black' }: { text: string; color?: string }) => {
|
|
12
|
-
return React.createElement('Text', { style: { color }, testID: 'simple-text' }, text);
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
describe('SimpleText Component', () => {
|
|
16
|
-
it('renders text correctly', () => {
|
|
17
|
-
const tree = ReactTestRenderer.create(<SimpleText text="Hello World" />);
|
|
18
|
-
const textComponent = tree.root.findByProps({ testID: 'simple-text' });
|
|
19
|
-
expect(textComponent.children).toEqual(['Hello World']);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it('applies custom color', () => {
|
|
23
|
-
const tree = ReactTestRenderer.create(<SimpleText text="Colored Text" color="red" />);
|
|
24
|
-
const textComponent = tree.root.findByProps({ testID: 'simple-text' });
|
|
25
|
-
expect(textComponent.props.style.color).toBe('red');
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it('uses default color when not specified', () => {
|
|
29
|
-
const tree = ReactTestRenderer.create(<SimpleText text="Default Color" />);
|
|
30
|
-
const textComponent = tree.root.findByProps({ testID: 'simple-text' });
|
|
31
|
-
expect(textComponent.props.style.color).toBe('black');
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
// Example 2: Button with Press Handler
|
|
36
|
-
const PressableButton = ({
|
|
37
|
-
title,
|
|
38
|
-
onPress,
|
|
39
|
-
disabled = false
|
|
40
|
-
}: {
|
|
41
|
-
title: string;
|
|
42
|
-
onPress: () => void;
|
|
43
|
-
disabled?: boolean;
|
|
44
|
-
}) => {
|
|
45
|
-
return React.createElement(
|
|
46
|
-
'TouchableOpacity',
|
|
47
|
-
{
|
|
48
|
-
testID: 'pressable-button',
|
|
49
|
-
onPress: disabled ? undefined : onPress,
|
|
50
|
-
style: { opacity: disabled ? 0.5 : 1 }
|
|
51
|
-
},
|
|
52
|
-
React.createElement('Text', { testID: 'button-text' }, title)
|
|
53
|
-
);
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
describe('PressableButton Component', () => {
|
|
57
|
-
it('renders button with title', () => {
|
|
58
|
-
const mockPress = jest.fn();
|
|
59
|
-
const tree = ReactTestRenderer.create(
|
|
60
|
-
<PressableButton title="Press Me" onPress={mockPress} />
|
|
61
|
-
);
|
|
62
|
-
|
|
63
|
-
const buttonText = tree.root.findByProps({ testID: 'button-text' });
|
|
64
|
-
expect(buttonText.children).toEqual(['Press Me']);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it('calls onPress when pressed', () => {
|
|
68
|
-
const mockPress = jest.fn();
|
|
69
|
-
const tree = ReactTestRenderer.create(
|
|
70
|
-
<PressableButton title="Press Me" onPress={mockPress} />
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
const button = tree.root.findByProps({ testID: 'pressable-button' });
|
|
74
|
-
ReactTestRenderer.act(() => {
|
|
75
|
-
button.props.onPress();
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
expect(mockPress).toHaveBeenCalledTimes(1);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it('does not call onPress when disabled', () => {
|
|
82
|
-
const mockPress = jest.fn();
|
|
83
|
-
const tree = ReactTestRenderer.create(
|
|
84
|
-
<PressableButton title="Disabled" onPress={mockPress} disabled />
|
|
85
|
-
);
|
|
86
|
-
|
|
87
|
-
const button = tree.root.findByProps({ testID: 'pressable-button' });
|
|
88
|
-
expect(button.props.onPress).toBeUndefined();
|
|
89
|
-
expect(button.props.style.opacity).toBe(0.5);
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
// Example 3: List Component
|
|
94
|
-
const ItemList = ({ items }: { items: string[] }) => {
|
|
95
|
-
return React.createElement(
|
|
96
|
-
'FlatList',
|
|
97
|
-
{
|
|
98
|
-
testID: 'item-list',
|
|
99
|
-
data: items,
|
|
100
|
-
renderItem: ({ item, index }: { item: string; index: number }) =>
|
|
101
|
-
React.createElement(
|
|
102
|
-
'View',
|
|
103
|
-
{ key: index, testID: `item-${index}` },
|
|
104
|
-
React.createElement('Text', { testID: `item-text-${index}` }, item)
|
|
105
|
-
),
|
|
106
|
-
keyExtractor: (item: string, index: number) => `${item}-${index}`
|
|
107
|
-
}
|
|
108
|
-
);
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
describe('ItemList Component', () => {
|
|
112
|
-
it('renders list with items', () => {
|
|
113
|
-
const items = ['Item 1', 'Item 2', 'Item 3'];
|
|
114
|
-
const tree = ReactTestRenderer.create(<ItemList items={items} />);
|
|
115
|
-
|
|
116
|
-
const flatList = tree.root.findByProps({ testID: 'item-list' });
|
|
117
|
-
expect(flatList.props.data).toEqual(items);
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
it('generates correct key extractor', () => {
|
|
121
|
-
const items = ['Apple', 'Banana'];
|
|
122
|
-
const tree = ReactTestRenderer.create(<ItemList items={items} />);
|
|
123
|
-
|
|
124
|
-
const flatList = tree.root.findByProps({ testID: 'item-list' });
|
|
125
|
-
const keyExtractor = flatList.props.keyExtractor;
|
|
126
|
-
|
|
127
|
-
expect(keyExtractor('Apple', 0)).toBe('Apple-0');
|
|
128
|
-
expect(keyExtractor('Banana', 1)).toBe('Banana-1');
|
|
129
|
-
});
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
// Example 4: Form Input Component
|
|
133
|
-
const TextInput = ({
|
|
134
|
-
value,
|
|
135
|
-
onChangeText,
|
|
136
|
-
placeholder,
|
|
137
|
-
secureTextEntry = false
|
|
138
|
-
}: {
|
|
139
|
-
value: string;
|
|
140
|
-
onChangeText: (text: string) => void;
|
|
141
|
-
placeholder?: string;
|
|
142
|
-
secureTextEntry?: boolean;
|
|
143
|
-
}) => {
|
|
144
|
-
return React.createElement('TextInput', {
|
|
145
|
-
testID: 'text-input',
|
|
146
|
-
value,
|
|
147
|
-
onChangeText,
|
|
148
|
-
placeholder,
|
|
149
|
-
secureTextEntry,
|
|
150
|
-
style: { borderWidth: 1, padding: 10 }
|
|
151
|
-
});
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
describe('TextInput Component', () => {
|
|
155
|
-
it('renders with initial value', () => {
|
|
156
|
-
const mockChange = jest.fn();
|
|
157
|
-
const tree = ReactTestRenderer.create(
|
|
158
|
-
<TextInput value="Initial Value" onChangeText={mockChange} />
|
|
159
|
-
);
|
|
160
|
-
|
|
161
|
-
const input = tree.root.findByProps({ testID: 'text-input' });
|
|
162
|
-
expect(input.props.value).toBe('Initial Value');
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
it('calls onChangeText when text changes', () => {
|
|
166
|
-
const mockChange = jest.fn();
|
|
167
|
-
const tree = ReactTestRenderer.create(
|
|
168
|
-
<TextInput value="" onChangeText={mockChange} />
|
|
169
|
-
);
|
|
170
|
-
|
|
171
|
-
const input = tree.root.findByProps({ testID: 'text-input' });
|
|
172
|
-
ReactTestRenderer.act(() => {
|
|
173
|
-
input.props.onChangeText('New Text');
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
expect(mockChange).toHaveBeenCalledWith('New Text');
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
it('shows placeholder when provided', () => {
|
|
180
|
-
const mockChange = jest.fn();
|
|
181
|
-
const tree = ReactTestRenderer.create(
|
|
182
|
-
<TextInput
|
|
183
|
-
value=""
|
|
184
|
-
onChangeText={mockChange}
|
|
185
|
-
placeholder="Enter text here"
|
|
186
|
-
/>
|
|
187
|
-
);
|
|
188
|
-
|
|
189
|
-
const input = tree.root.findByProps({ testID: 'text-input' });
|
|
190
|
-
expect(input.props.placeholder).toBe('Enter text here');
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
it('enables secure text entry when specified', () => {
|
|
194
|
-
const mockChange = jest.fn();
|
|
195
|
-
const tree = ReactTestRenderer.create(
|
|
196
|
-
<TextInput
|
|
197
|
-
value=""
|
|
198
|
-
onChangeText={mockChange}
|
|
199
|
-
secureTextEntry
|
|
200
|
-
/>
|
|
201
|
-
);
|
|
202
|
-
|
|
203
|
-
const input = tree.root.findByProps({ testID: 'text-input' });
|
|
204
|
-
expect(input.props.secureTextEntry).toBe(true);
|
|
205
|
-
});
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
// Example 5: Component with Hooks
|
|
209
|
-
const Counter = ({ initialValue = 0 }: { initialValue?: number }) => {
|
|
210
|
-
const [count, setCount] = React.useState(initialValue);
|
|
211
|
-
|
|
212
|
-
return React.createElement(
|
|
213
|
-
'View',
|
|
214
|
-
{ testID: 'counter-container' },
|
|
215
|
-
React.createElement('Text', { testID: 'counter-value' }, count.toString()),
|
|
216
|
-
React.createElement(
|
|
217
|
-
'TouchableOpacity',
|
|
218
|
-
{
|
|
219
|
-
testID: 'increment-button',
|
|
220
|
-
onPress: () => setCount(prev => prev + 1)
|
|
221
|
-
},
|
|
222
|
-
React.createElement('Text', null, '+')
|
|
223
|
-
),
|
|
224
|
-
React.createElement(
|
|
225
|
-
'TouchableOpacity',
|
|
226
|
-
{
|
|
227
|
-
testID: 'decrement-button',
|
|
228
|
-
onPress: () => setCount(prev => prev - 1)
|
|
229
|
-
},
|
|
230
|
-
React.createElement('Text', null, '-')
|
|
231
|
-
),
|
|
232
|
-
React.createElement(
|
|
233
|
-
'TouchableOpacity',
|
|
234
|
-
{
|
|
235
|
-
testID: 'reset-button',
|
|
236
|
-
onPress: () => setCount(initialValue)
|
|
237
|
-
},
|
|
238
|
-
React.createElement('Text', null, 'Reset')
|
|
239
|
-
)
|
|
240
|
-
);
|
|
241
|
-
};
|
|
242
|
-
|
|
243
|
-
describe('Counter Component', () => {
|
|
244
|
-
it('renders with initial value', () => {
|
|
245
|
-
const tree = ReactTestRenderer.create(<Counter initialValue={5} />);
|
|
246
|
-
const counterValue = tree.root.findByProps({ testID: 'counter-value' });
|
|
247
|
-
expect(counterValue.children).toEqual(['5']);
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
it('increments counter when increment button is pressed', () => {
|
|
251
|
-
const tree = ReactTestRenderer.create(<Counter />);
|
|
252
|
-
const counterValue = tree.root.findByProps({ testID: 'counter-value' });
|
|
253
|
-
const incrementButton = tree.root.findByProps({ testID: 'increment-button' });
|
|
254
|
-
|
|
255
|
-
expect(counterValue.children).toEqual(['0']);
|
|
256
|
-
|
|
257
|
-
ReactTestRenderer.act(() => {
|
|
258
|
-
incrementButton.props.onPress();
|
|
259
|
-
});
|
|
260
|
-
|
|
261
|
-
expect(counterValue.children).toEqual(['1']);
|
|
262
|
-
});
|
|
263
|
-
|
|
264
|
-
it('decrements counter when decrement button is pressed', () => {
|
|
265
|
-
const tree = ReactTestRenderer.create(<Counter initialValue={10} />);
|
|
266
|
-
const counterValue = tree.root.findByProps({ testID: 'counter-value' });
|
|
267
|
-
const decrementButton = tree.root.findByProps({ testID: 'decrement-button' });
|
|
268
|
-
|
|
269
|
-
expect(counterValue.children).toEqual(['10']);
|
|
270
|
-
|
|
271
|
-
ReactTestRenderer.act(() => {
|
|
272
|
-
decrementButton.props.onPress();
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
expect(counterValue.children).toEqual(['9']);
|
|
276
|
-
});
|
|
277
|
-
|
|
278
|
-
it('resets counter to initial value when reset is pressed', () => {
|
|
279
|
-
const tree = ReactTestRenderer.create(<Counter initialValue={5} />);
|
|
280
|
-
const counterValue = tree.root.findByProps({ testID: 'counter-value' });
|
|
281
|
-
const incrementButton = tree.root.findByProps({ testID: 'increment-button' });
|
|
282
|
-
const resetButton = tree.root.findByProps({ testID: 'reset-button' });
|
|
283
|
-
|
|
284
|
-
// Increment a few times
|
|
285
|
-
ReactTestRenderer.act(() => {
|
|
286
|
-
incrementButton.props.onPress();
|
|
287
|
-
incrementButton.props.onPress();
|
|
288
|
-
});
|
|
289
|
-
|
|
290
|
-
expect(counterValue.children).toEqual(['7']);
|
|
291
|
-
|
|
292
|
-
// Reset
|
|
293
|
-
ReactTestRenderer.act(() => {
|
|
294
|
-
resetButton.props.onPress();
|
|
295
|
-
});
|
|
296
|
-
|
|
297
|
-
expect(counterValue.children).toEqual(['5']);
|
|
298
|
-
});
|
|
299
|
-
});
|
|
300
|
-
});
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
presets: ['module:@react-native/babel-preset'],
|
|
3
|
-
plugins: [
|
|
4
|
-
['react-native-unistyles/plugin', {
|
|
5
|
-
root: 'src',
|
|
6
|
-
autoProcessPaths: ['@idealyst/components', '@idealyst/navigation', '@idealyst/theme'],
|
|
7
|
-
}],
|
|
8
|
-
'react-native-reanimated/plugin'
|
|
9
|
-
],
|
|
10
|
-
};
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
# Dependencies
|
|
2
|
-
node_modules/
|
|
3
|
-
|
|
4
|
-
# React Native
|
|
5
|
-
|
|
6
|
-
# Xcode
|
|
7
|
-
*.pbxuser
|
|
8
|
-
!default.pbxuser
|
|
9
|
-
*.mode1v3
|
|
10
|
-
!default.mode1v3
|
|
11
|
-
*.mode2v3
|
|
12
|
-
!default.mode2v3
|
|
13
|
-
*.perspectivev3
|
|
14
|
-
!default.perspectivev3
|
|
15
|
-
xcuserdata
|
|
16
|
-
*.xccheckout
|
|
17
|
-
*.moved-aside
|
|
18
|
-
DerivedData
|
|
19
|
-
*.hmap
|
|
20
|
-
*.ipa
|
|
21
|
-
*.xcuserstate
|
|
22
|
-
project.xcworkspace
|
|
23
|
-
|
|
24
|
-
# Android/IntelliJ
|
|
25
|
-
build/
|
|
26
|
-
.idea
|
|
27
|
-
.gradle
|
|
28
|
-
local.properties
|
|
29
|
-
*.iml
|
|
30
|
-
*.hprof
|
|
31
|
-
.cxx/
|
|
32
|
-
|
|
33
|
-
# BUCK
|
|
34
|
-
buck-out/
|
|
35
|
-
\.buckd/
|
|
36
|
-
*.keystore
|
|
37
|
-
!debug.keystore
|
|
38
|
-
|
|
39
|
-
# Bundle artifacts
|
|
40
|
-
*.jsbundle
|
|
41
|
-
|
|
42
|
-
# CocoaPods
|
|
43
|
-
/ios/Pods/
|
|
44
|
-
|
|
45
|
-
# Environment variables
|
|
46
|
-
.env
|
|
47
|
-
.env.local
|
|
48
|
-
.env.development.local
|
|
49
|
-
.env.test.local
|
|
50
|
-
.env.production.local
|
|
51
|
-
|
|
52
|
-
# Logs
|
|
53
|
-
npm-debug.log*
|
|
54
|
-
yarn-debug.log*
|
|
55
|
-
yarn-error.log*
|
|
56
|
-
|
|
57
|
-
# Coverage
|
|
58
|
-
coverage/
|
|
59
|
-
*.lcov
|
|
60
|
-
.nyc_output
|
|
61
|
-
|
|
62
|
-
# Metro
|
|
63
|
-
.metro-health-check*
|
|
64
|
-
|
|
65
|
-
# IDE
|
|
66
|
-
.vscode/
|
|
67
|
-
*.swp
|
|
68
|
-
*.swo
|
|
69
|
-
*~
|
|
70
|
-
|
|
71
|
-
# OS
|
|
72
|
-
.DS_Store
|
|
73
|
-
Thumbs.db
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
preset: 'react-native',
|
|
3
|
-
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
|
|
4
|
-
testMatch: [
|
|
5
|
-
'**/__tests__/**/*.{ts,tsx,js}',
|
|
6
|
-
'**/*.{test,spec}.{ts,tsx,js}'
|
|
7
|
-
],
|
|
8
|
-
transform: {
|
|
9
|
-
'^.+\\.(js|jsx|ts|tsx)$': 'babel-jest',
|
|
10
|
-
},
|
|
11
|
-
transformIgnorePatterns: [
|
|
12
|
-
'node_modules/(?!(react-native|@react-native|@idealyst)/)',
|
|
13
|
-
],
|
|
14
|
-
collectCoverageFrom: [
|
|
15
|
-
'src/**/*.{ts,tsx}',
|
|
16
|
-
'!src/**/*.d.ts',
|
|
17
|
-
'!src/**/index.ts',
|
|
18
|
-
],
|
|
19
|
-
coverageDirectory: 'coverage',
|
|
20
|
-
testEnvironment: 'jsdom',
|
|
21
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
// Global test setup for React Native tests
|
|
2
|
-
import 'react-native-gesture-handler/jestSetup';
|
|
3
|
-
|
|
4
|
-
// Mock react-native modules that are not available in test environment
|
|
5
|
-
jest.mock('react-native-reanimated', () => {
|
|
6
|
-
const Reanimated = require('react-native-reanimated/mock');
|
|
7
|
-
Reanimated.default.call = () => {};
|
|
8
|
-
return Reanimated;
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
// Silence the warning: Animated: `useNativeDriver` is not supported
|
|
12
|
-
jest.mock('react-native/Libraries/Animated/NativeAnimatedHelper');
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
|
|
4
|
-
const { wrapWithReanimatedMetroConfig } = require('react-native-reanimated/metro-config');
|
|
5
|
-
|
|
6
|
-
const config = {
|
|
7
|
-
projectRoot: __dirname,
|
|
8
|
-
watchFolders: [
|
|
9
|
-
// Add the workspace root to watch folders so Metro can find hoisted node_modules
|
|
10
|
-
path.resolve(__dirname, '../..'),
|
|
11
|
-
],
|
|
12
|
-
resolver: {
|
|
13
|
-
nodeModulesPaths: [
|
|
14
|
-
path.resolve(__dirname, 'node_modules'),
|
|
15
|
-
// Add the workspace root node_modules for hoisted packages
|
|
16
|
-
path.resolve(__dirname, '../..', 'node_modules'),
|
|
17
|
-
],
|
|
18
|
-
// Important for Idealyst to use .native extensions for React Native (eg: @idealyst/components/src/Button/Button.native.tsx)
|
|
19
|
-
sourceExts: ['native.tsx', 'native.ts', 'tsx', 'ts', 'native.jsx', 'native.js', 'jsx', 'js', 'json', 'cjs'],
|
|
20
|
-
extraNodeModules: {
|
|
21
|
-
// Redirect react and react-native imports to the local node_modules
|
|
22
|
-
react: path.resolve(__dirname, 'node_modules/react'),
|
|
23
|
-
'react-native': path.resolve(__dirname, 'node_modules/react-native'),
|
|
24
|
-
// Ensure Idealyst packages use mobile's node_modules
|
|
25
|
-
'@idealyst/components': path.resolve(__dirname, 'node_modules/@idealyst/components'),
|
|
26
|
-
'@idealyst/navigation': path.resolve(__dirname, 'node_modules/@idealyst/navigation'),
|
|
27
|
-
'@idealyst/theme': path.resolve(__dirname, 'node_modules/@idealyst/theme'),
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
watcher: {
|
|
31
|
-
// When configuring custom components with .native extensions, make sure the watcher looks for them
|
|
32
|
-
additionalExts: ['native.tsx', 'native.ts', 'native.jsx', 'native.js'],
|
|
33
|
-
},
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
module.exports = wrapWithReanimatedMetroConfig(mergeConfig(getDefaultConfig(__dirname), config));
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@{{workspaceScope}}/mobile",
|
|
3
|
-
"version": "{{version}}",
|
|
4
|
-
"description": "{{description}}",
|
|
5
|
-
"private": true,
|
|
6
|
-
"scripts": {
|
|
7
|
-
"start": "react-native start",
|
|
8
|
-
"ios": "react-native run-ios",
|
|
9
|
-
"android": "react-native run-android",
|
|
10
|
-
"test": "jest",
|
|
11
|
-
"test:watch": "jest --watch",
|
|
12
|
-
"test:coverage": "jest --coverage",
|
|
13
|
-
"lint": "eslint . --ext .js,.jsx,.ts,.tsx"
|
|
14
|
-
},
|
|
15
|
-
"dependencies": {
|
|
16
|
-
"@idealyst/components": "^{{idealystVersion}}",
|
|
17
|
-
"@idealyst/navigation": "^{{idealystVersion}}",
|
|
18
|
-
"@idealyst/theme": "^{{idealystVersion}}",
|
|
19
|
-
"@{{workspaceScope}}/shared": "workspace:*",
|
|
20
|
-
"@{{workspaceScope}}/database": "workspace:*",
|
|
21
|
-
"@tanstack/react-query": "^5.83.0",
|
|
22
|
-
"@trpc/client": "^11.5.1",
|
|
23
|
-
"@trpc/react-query": "^11.5.1",
|
|
24
|
-
"@trpc/server": "^11.5.1",
|
|
25
|
-
"react": "^19.2.0",
|
|
26
|
-
"react-native": "^0.83.1",
|
|
27
|
-
"react-native-edge-to-edge": "^1.6.2",
|
|
28
|
-
"react-native-gesture-handler": "^2.27.1",
|
|
29
|
-
"react-native-nitro-modules": "^0.30.0",
|
|
30
|
-
"react-native-reanimated": "^4.1.3",
|
|
31
|
-
"react-native-safe-area-context": "^5.5.1",
|
|
32
|
-
"react-native-screens": "^4.11.1",
|
|
33
|
-
"react-native-svg": "^15.8.0",
|
|
34
|
-
"react-native-unistyles": "^3.0.4",
|
|
35
|
-
"react-native-vector-icons": "^10.2.0",
|
|
36
|
-
"react-native-worklets": "^0.6.1"
|
|
37
|
-
},
|
|
38
|
-
"devDependencies": {
|
|
39
|
-
"@babel/core": "^7.20.0",
|
|
40
|
-
"@babel/preset-env": "^7.20.0",
|
|
41
|
-
"@babel/runtime": "^7.20.0",
|
|
42
|
-
"@react-native/babel-preset": "^0.83.0",
|
|
43
|
-
"@react-native/eslint-config": "^0.83.0",
|
|
44
|
-
"@react-native/metro-config": "^0.83.0",
|
|
45
|
-
"@react-native/typescript-config": "^0.83.0",
|
|
46
|
-
"@types/jest": "^29.5.12",
|
|
47
|
-
"@types/react": "^19.2.0",
|
|
48
|
-
"@types/react-test-renderer": "^19.0.0",
|
|
49
|
-
"eslint": "^8.19.0",
|
|
50
|
-
"jest": "^29.6.3",
|
|
51
|
-
"metro-react-native-babel-preset": "^0.76.8",
|
|
52
|
-
"prettier": "^2.4.1",
|
|
53
|
-
"react-test-renderer": "^19.2.0",
|
|
54
|
-
"typescript": "^5.0.4"
|
|
55
|
-
},
|
|
56
|
-
"idealyst": {
|
|
57
|
-
"framework": "react-native",
|
|
58
|
-
"version": "1.0.3"
|
|
59
|
-
}
|
|
60
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "@react-native/typescript-config/tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"allowJs": true,
|
|
5
|
-
"allowSyntheticDefaultImports": true,
|
|
6
|
-
"esModuleInterop": true,
|
|
7
|
-
"isolatedModules": true,
|
|
8
|
-
"jsx": "react-native",
|
|
9
|
-
"lib": ["es2017"],
|
|
10
|
-
"noEmit": true,
|
|
11
|
-
"strict": true,
|
|
12
|
-
"target": "esnext",
|
|
13
|
-
"skipLibCheck": true,
|
|
14
|
-
"baseUrl": "./",
|
|
15
|
-
"paths": {
|
|
16
|
-
"@/*": ["./src/*"]
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
"include": [
|
|
20
|
-
"src/**/*",
|
|
21
|
-
"index.js"
|
|
22
|
-
],
|
|
23
|
-
"exclude": [
|
|
24
|
-
"node_modules",
|
|
25
|
-
"android",
|
|
26
|
-
"ios"
|
|
27
|
-
]
|
|
28
|
-
}
|