Skip to content

Commit

Permalink
Add two more test cases to get to 100% code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian-Holbrook committed Feb 8, 2024
1 parent 13e6a70 commit 52cb24f
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/RokuDeploy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1208,6 +1208,38 @@ describe('index', () => {
assert.fail('Should not have throw');
}
});

it('should fail with HTTP_INVALID_CONSTANT and then fail on retry', async () => {
let doPostStub = sinon.stub(rokuDeploy as any, 'doPostRequest');
doPostStub.onFirstCall().throws((params) => {
throw new HPE_INVALID_CONSTANT_ERROR();
});
doPostStub.onSecondCall().returns({ body: '..."fileType":"zip"...' });
try {
await rokuDeploy.convertToSquashfs(options);
} catch (e) {
expect(e).to.be.instanceof(errors.ConvertError);
return;
}
assert.fail('Should not have throw');
});

it('should fail with HTTP_INVALID_CONSTANT and then throw on retry', async () => {
let doPostStub = sinon.stub(rokuDeploy as any, 'doPostRequest');
doPostStub.onFirstCall().throws((params) => {
throw new HPE_INVALID_CONSTANT_ERROR();
});
doPostStub.onSecondCall().throws((params) => {
throw new Error('Never seen');
});
try {
await rokuDeploy.convertToSquashfs(options);
} catch (e) {
expect(e).to.be.instanceof(HPE_INVALID_CONSTANT_ERROR);
return;
}
assert.fail('Should not have throw');
});
});

class HPE_INVALID_CONSTANT_ERROR extends Error {
Expand Down

0 comments on commit 52cb24f

Please sign in to comment.