Skip to content
Draft
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
37 changes: 37 additions & 0 deletions src/BrightScriptCommands.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,43 @@ describe('BrightScriptFileUtils ', () => {
});
});

describe('refreshDeviceList / rescanDevices', () => {
let capturedCommands: Record<string, (...args: any[]) => any>;
let deviceManager: any;

beforeEach(() => {
deviceManager = {
submitOrders: sinon.stub(),
broadcast: sinon.stub(),
reconcile: sinon.stub()
};
const localCommands = new BrightScriptCommands({} as any, {} as any, vscode.context, deviceManager, {} as any, {} as any, {} as any, {} as any);
capturedCommands = {};
sinon.stub(vscode.commands as any, 'registerCommand').callsFake((name: any, cb: any) => {
capturedCommands[name] = cb;
});
localCommands.registerCommands();
});

afterEach(() => {
(vscode.commands.registerCommand as any).restore();
});

it('refreshDeviceList submits refresh orders instead of scanning directly', () => {
capturedCommands['extension.brightscript.refreshDeviceList']();
assert.isTrue(deviceManager.submitOrders.calledOnceWith([{ type: 'broadcast', reason: 'refresh-clicked' }, { type: 'reconcile', reason: 'refresh-clicked' }]));
assert.isTrue(deviceManager.broadcast.notCalled);
assert.isTrue(deviceManager.reconcile.notCalled);
});

it('rescanDevices submits refresh orders instead of scanning directly', () => {
capturedCommands['extension.brightscript.rescanDevices']();
assert.isTrue(deviceManager.submitOrders.calledOnceWith([{ type: 'broadcast', reason: 'refresh-clicked' }, { type: 'reconcile', reason: 'refresh-clicked' }]));
assert.isTrue(deviceManager.broadcast.notCalled);
assert.isTrue(deviceManager.reconcile.notCalled);
});
});

describe('setDefaultDevicePassword', () => {
let localCommands: BrightScriptCommands;
let capturedCommands: Record<string, (...args: any[]) => any>;
Expand Down
12 changes: 9 additions & 3 deletions src/BrightScriptCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,17 @@ export class BrightScriptCommands {

//the "Refresh" button in the Devices list
this.registerCommand('refreshDeviceList', (key: string) => {
this.deviceManager.refresh(true);
this.deviceManager.submitOrders([
{ type: 'broadcast', reason: 'refresh-clicked' },
{ type: 'reconcile', reason: 'refresh-clicked' }
]);
});

this.registerCommand('rescanDevices', () => {
this.deviceManager.refresh(true);
this.deviceManager.submitOrders([
{ type: 'broadcast', reason: 'refresh-clicked' },
{ type: 'reconcile', reason: 'refresh-clicked' }
]);
});

// Refresh a single device (inline button on hover in devices panel)
Expand Down Expand Up @@ -349,7 +355,7 @@ export class BrightScriptCommands {

this.registerCommand('clearCurrentDeviceList', async () => {
const toatsPromise = util.showTimedNotification('Clearing device list');
await this.deviceManager.clearCurrentDeviceList();
this.deviceManager.clearCurrentDeviceList();
await toatsPromise;
});

Expand Down
Loading
Loading