Skip to content

Commit

Permalink
chore: clean up code and resolve patch-package issue
Browse files Browse the repository at this point in the history
  • Loading branch information
byCedric committed Dec 19, 2024
1 parent 1a52965 commit a8e6e9c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 57 deletions.
2 changes: 1 addition & 1 deletion patches/jest-snapshot+28.1.3.patch
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ index a3d3b05..69f0132 100644
+
const keys = [
['resolveSnapshotPath', 'function'],
['resolveTestPath', 'function'],
['resolveTestPath', 'function'],
51 changes: 1 addition & 50 deletions src/expo/__tests__/bundler.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { expect } from 'chai';

import { mockDevice } from '../../__tests__/utils/debugging';
import { stubFetch, withFetchError, withFetchResponse } from '../../__tests__/utils/fetch';
import { stubFetch } from '../../__tests__/utils/fetch';
import {
type InspectableDevice,
fetchDevicesToInspect,
fetchDevicesToInspectFromUnknownWorkflow,
findDeviceByName,
inferDevicePlatform,
} from '../bundler';
Expand Down Expand Up @@ -59,54 +58,6 @@ describe('fetchDevicesToInspect', () => {
});
});

describe('fetchDevicesToInspectFromUnknownWorkflow', () => {
it('fetches devices from modern and classic bundler addresses', async () => {
using fetch = stubFetch();

await fetchDevicesToInspectFromUnknownWorkflow({ host });

expect(fetch).to.be.calledWith(`http://${host}:19000/json/list`);
expect(fetch).to.be.calledWith(`http://${host}:8081/json/list`);
});

it('returns devices from modern bundler address', async () => {
const device = mockDevice({ deviceName: 'iPhone 7 Pro' });
using fetch = stubFetch();

withFetchError(fetch.withArgs(`http://${host}:19000/json/list`));
withFetchResponse(fetch.withArgs(`http://${host}:8081/json/list`), [device]);

const devices = await fetchDevicesToInspectFromUnknownWorkflow({ host });

expect(devices).to.deep.equal([device]);
});

it('returns devices from classic bundler address', async () => {
const device = mockDevice({ deviceName: 'Pixel 7 Pro' });
using fetch = stubFetch();

withFetchResponse(fetch.withArgs(`http://${host}:19000/json/list`), [device]);
withFetchError(fetch.withArgs(`http://${host}:8081/json/list`));

const devices = await fetchDevicesToInspectFromUnknownWorkflow({ host });

expect(devices).to.deep.equal([device]);
});

it('prioritizes modern bundler address', async () => {
const iphone = mockDevice({ deviceName: 'iPhone 15 Pro' });
const android = mockDevice({ deviceName: 'Pixel 7 Pro' });
using fetch = stubFetch();

withFetchResponse(fetch.withArgs(`http://${host}:19000/json/list`), [iphone]);
withFetchResponse(fetch.withArgs(`http://${host}:8081/json/list`), [android]);

const devices = await fetchDevicesToInspectFromUnknownWorkflow({ host });

expect(devices).to.deep.equal([android]);
});
});

describe('findDeviceByName', () => {
it('returns first device by its name', () => {
const target = mockDevice({ deviceName: 'iPhone 15 Pro', id: 'page1' });
Expand Down
7 changes: 1 addition & 6 deletions src/expoDebuggers.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import fs from 'fs';
import vscode from 'vscode';

import {
fetchDevicesToInspect,
askDeviceByName,
inferDevicePlatform,
fetchDevicesToInspectFromUnknownWorkflow,
} from './expo/bundler';
import { fetchDevicesToInspect, askDeviceByName, inferDevicePlatform } from './expo/bundler';
import {
ExpoProjectCache,
ExpoProject,
Expand Down

0 comments on commit a8e6e9c

Please sign in to comment.