Skip to content

fix: fix stop run on device when the method is called with empty array #4794

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/controllers/run-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class RunController extends EventEmitter implements IRunController {
// so we cannot await it as this will cause infinite loop.
const shouldAwaitPendingOperation = !stopOptions || stopOptions.shouldAwaitAllActions;

const deviceIdentifiersToRemove = deviceIdentifiers || _.map(liveSyncProcessInfo.deviceDescriptors, d => d.identifier);
const deviceIdentifiersToRemove = (deviceIdentifiers && deviceIdentifiers.length) ? deviceIdentifiers : _.map(liveSyncProcessInfo.deviceDescriptors, d => d.identifier);

const removedDeviceIdentifiers = _.remove(liveSyncProcessInfo.deviceDescriptors, descriptor => _.includes(deviceIdentifiersToRemove, descriptor.identifier))
.map(descriptor => descriptor.identifier);
Expand Down
6 changes: 6 additions & 0 deletions test/controllers/run-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,12 @@ describe("RunController", () => {
currentDeviceIdentifiers: ["device1", "device2", "device3"],
expectedDeviceIdentifiers: ["device1"],
deviceIdentifiersToBeStopped: ["device1", "device4"]
},
{
name: "stops LiveSync operation for all devices when stop method is called with empty array",
currentDeviceIdentifiers: ["device1", "device2", "device3"],
expectedDeviceIdentifiers: ["device1", "device2", "device3"],
deviceIdentifiersToBeStopped: []
}
];

Expand Down