MCPcopy
hub / github.com/callstack/agent-device / createStubClient

Function createStubClient

src/__tests__/cli-client-commands.test.ts:1074–1207  ·  view source on GitHub ↗
(params: {
  installFromSource: AgentDeviceClient['apps']['installFromSource'];
  listApps?: AgentDeviceClient['apps']['list'];
  prepareMetro?: AgentDeviceClient['metro']['prepare'];
  reloadMetro?: AgentDeviceClient['metro']['reload'];
  open?: AgentDeviceClient['apps']['open'];
  screenshot?: AgentDeviceClient['capture']['screenshot'];
  updateSettings?: AgentDeviceClient['settings']['update'];
})

Source from the content-addressed store, hash-verified

1072}
1073
1074function createStubClient(params: {
1075 installFromSource: AgentDeviceClient['apps']['installFromSource'];
1076 listApps?: AgentDeviceClient['apps']['list'];
1077 prepareMetro?: AgentDeviceClient['metro']['prepare'];
1078 reloadMetro?: AgentDeviceClient['metro']['reload'];
1079 open?: AgentDeviceClient['apps']['open'];
1080 screenshot?: AgentDeviceClient['capture']['screenshot'];
1081 updateSettings?: AgentDeviceClient['settings']['update'];
1082}): AgentDeviceClient {
1083 const unexpectedCommandCall = async (): Promise<never> => {
1084 throw new Error('unexpected command call');
1085 };
1086 const command = createThrowingMethodGroup<AgentDeviceClient['command']>();
1087 return {
1088 command,
1089 devices: {
1090 list: async () => [],
1091 boot: unexpectedCommandCall,
1092 shutdown: unexpectedCommandCall,
1093 },
1094 sessions: {
1095 list: async () => [],
1096 stateDir: async () => '/tmp/agent-device-state',
1097 close: async () => ({ session: 'default', identifiers: { session: 'default' } }),
1098 artifacts: unexpectedCommandCall,
1099 },
1100 apps: {
1101 install: async () => ({
1102 app: 'Demo',
1103 appPath: '/tmp/Demo.app',
1104 platform: 'ios',
1105 identifiers: { appId: 'com.example.demo' },
1106 }),
1107 reinstall: async () => ({
1108 app: 'Demo',
1109 appPath: '/tmp/Demo.app',
1110 platform: 'ios',
1111 identifiers: { appId: 'com.example.demo' },
1112 }),
1113 installFromSource: params.installFromSource,
1114 list: params.listApps ?? (async () => []),
1115 open:
1116 params.open ??
1117 (async () => ({
1118 session: 'default',
1119 identifiers: { session: 'default' },
1120 })),
1121 close: async () => ({
1122 session: 'default',
1123 identifiers: { session: 'default' },
1124 }),
1125 push: unexpectedCommandCall,
1126 triggerEvent: unexpectedCommandCall,
1127 },
1128 materializations: {
1129 release: async (options) => ({
1130 released: true,
1131 materializationId: options.materializationId,

Callers 1

Calls 1

Tested by

no test coverage detected