Skip to content

Commit

Permalink
add end-to-end tests for particle usb dfu command
Browse files Browse the repository at this point in the history
  • Loading branch information
busticated committed Mar 3, 2020
1 parent 62e59dd commit f201d05
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion test/e2e/usb.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ describe('USB Commands [@device]', () => {
expect(subproc.exitCode).to.equal(1);
});

it('Sets and clears the setup done flag', async function test() {
it('Sets and clears the setup done flag', async () => {
await cli.run(['usb', 'setup-done', '--reset']);
await delay(2000);

Expand All @@ -112,4 +112,31 @@ describe('USB Commands [@device]', () => {
expect(subproc.stderr).to.equal('');
expect(subproc.exitCode).to.equal(0);
});

it('Enters DFU mode with confirmation', async () => {
await cli.run(['usb', 'dfu', DEVICE_ID]);

const platform = capitalize(DEVICE_PLATFORM_NAME);
const { stdout, stderr, exitCode } = await cli.run(['usb', 'list']);
expect(stdout).to.include(`${DEVICE_NAME} [${DEVICE_ID}] (${platform}, DFU)`);
expect(stderr).to.equal('');
expect(exitCode).to.equal(0);

await cli.run(['usb', 'reset']);
await delay(2000);

const subproc = await cli.run(['usb', 'list']);
expect(subproc.stdout).to.include(`${DEVICE_NAME} [${DEVICE_ID}] (${platform})`);
expect(subproc.stderr).to.equal('');
expect(subproc.exitCode).to.equal(0);
});

it('Fails to enter DFU mode when device is unrecognized', async () => {
const device = 'DOESNOTEXIST';
const { stdout, stderr, exitCode } = await cli.run(['usb', 'dfu', device]);

expect(stdout).to.equal(`Device not found: ${device}`);
expect(stderr).to.equal('');
expect(exitCode).to.equal(1);
});
});

0 comments on commit f201d05

Please sign in to comment.