Improve device destruction code [8/n]

Summary: Some cleanup in device destruction code. This diff wraps up the stack that decouples device management from the UI. Next steps are client management, and system management (file access / command execution)

Reviewed By: passy

Differential Revision: D31084036

fbshipit-source-id: 93efee7dba2193589d3c08c51128ce03de5eff7f
This commit is contained in:
Michel Weststrate
2021-09-27 02:11:40 -07:00
committed by Facebook GitHub Bot
parent dce92b16db
commit 987755bb09
4 changed files with 30 additions and 15 deletions

View File

@@ -21,7 +21,7 @@ afterEach(() => {
_setFlipperLibImplementation(undefined);
});
test('doing a double REGISTER_DEVICE keeps the last', () => {
test('doing a double REGISTER_DEVICE fails', () => {
const device1 = new TestDevice('serial', 'physical', 'title', 'Android');
const device2 = new TestDevice('serial', 'physical', 'title2', 'Android');
const initialState: State = reducer(undefined, {
@@ -31,12 +31,12 @@ test('doing a double REGISTER_DEVICE keeps the last', () => {
expect(initialState.devices.length).toBe(1);
expect(initialState.devices[0]).toBe(device1);
const endState = reducer(initialState, {
type: 'REGISTER_DEVICE',
payload: device2,
});
expect(endState.devices.length).toBe(1);
expect(endState.devices[0]).toBe(device2);
expect(() => {
reducer(initialState, {
type: 'REGISTER_DEVICE',
payload: device2,
});
}).toThrow('still connected');
});
test('register, remove, re-register a metro device works correctly', () => {