Skip to content

Commit

Permalink
[tests] minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
keeramis committed Jun 21, 2024
1 parent 5d614ce commit fbdfd5b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 13 deletions.
2 changes: 1 addition & 1 deletion src/cmd/binary.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('Binary Inspect', () => {
let error;
let resPath;
try {
resPath = await binaryCommand.createProtectedBinary({ saveTo, params: { filename } }, false);
resPath = await binaryCommand.createProtectedBinary({ saveTo, file: filename, verbose: false });
} catch (err) {
error = err;
}
Expand Down
12 changes: 0 additions & 12 deletions src/cmd/device-protection.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ describe('DeviceProtectionCommands', () => {

describe('disableProtection', () => {
it('should disable protection on the device', async () => {
// Stub the necessary methods
sinon.stub(deviceProtectionCommands, '_getDeviceProtection')
.onFirstCall().resolves({ protected: true, overridden: false })
.onSecondCall().resolves({ protected: true, overridden: false });
Expand All @@ -51,7 +50,6 @@ describe('DeviceProtectionCommands', () => {
};


// Call the method
await deviceProtectionCommands.disableProtection();

expect(deviceProtectionCommands._getDeviceProtection).to.have.been.calledOnce;
Expand All @@ -60,7 +58,6 @@ describe('DeviceProtectionCommands', () => {
});

it('should disable protection on the device', async () => {
// Stub the necessary methods
sinon.stub(deviceProtectionCommands, '_getDeviceProtection')
.onFirstCall().resolves({ protected: true, overridden: false })
.onSecondCall().resolves({ protected: true, overridden: false });
Expand All @@ -76,7 +73,6 @@ describe('DeviceProtectionCommands', () => {
sinon.stub(deviceProtectionCommands,'_markAsDevelopmentDevice').resolves(true);


// Call the method
await deviceProtectionCommands.disableProtection({ open: true });

expect(deviceProtectionCommands._getDeviceProtection).to.have.been.calledOnce;
Expand All @@ -99,7 +95,6 @@ describe('DeviceProtectionCommands', () => {

describe('enableProtection', () => {
it('should enable protection on the device', async () => {
// Stub the necessary methods
sinon.stub(deviceProtectionCommands, '_getDeviceProtection').resolves({
protected: false,
overridden: false
Expand All @@ -111,7 +106,6 @@ describe('DeviceProtectionCommands', () => {
sinon.stub(deviceProtectionCommands, '_flashBootloader').resolves();
sinon.stub(deviceProtectionCommands, '_markAsDevelopmentDevice').resolves(true);

// Call the method
await deviceProtectionCommands.enableProtection();

expect(deviceProtectionCommands._getDeviceString).to.have.been.calledOnce;
Expand All @@ -123,23 +117,20 @@ describe('DeviceProtectionCommands', () => {


it('handles already protected devices', async () => {
// Stub the necessary methods
sinon.stub(deviceProtectionCommands, '_getDeviceProtection').resolves({
protected: true,
overridden: false
});
sinon.stub(deviceProtectionCommands, '_getDeviceString').resolves('[123456789abcdef] (Product 12345)');
sinon.stub(deviceProtectionCommands, '_isDeviceProtectionActiveInProduct').resolves();

// Call the method
await deviceProtectionCommands.enableProtection();

expect(deviceProtectionCommands._getDeviceProtection).to.have.been.calledOnce;
expect(deviceProtectionCommands._isDeviceProtectionActiveInProduct).to.not.have.been.called;
});

it('protects a service mode device', async () => {
// Stub the necessary methods
sinon.stub(deviceProtectionCommands, '_getDeviceProtection').resolves({
protected: true,
overridden: true
Expand All @@ -148,15 +139,13 @@ describe('DeviceProtectionCommands', () => {
sinon.stub(deviceProtectionCommands, '_isDeviceProtectionActiveInProduct').resolves(true);
sinon.stub(deviceProtectionCommands, '_markAsDevelopmentDevice').resolves(true);

// Call the method
await deviceProtectionCommands.enableProtection();

expect(deviceProtectionCommands._getDeviceProtection).to.have.been.calledOnce;
expect(deviceProtectionCommands._isDeviceProtectionActiveInProduct).to.not.have.been.called;
});

it('does not protect an open device if it is not in a product', async () => {
// Stub the necessary methods
sinon.stub(deviceProtectionCommands, '_getDeviceProtection').resolves({
protected: false,
overridden: false
Expand All @@ -166,7 +155,6 @@ describe('DeviceProtectionCommands', () => {
sinon.stub(deviceProtectionCommands, '_markAsDevelopmentDevice').resolves(true);
sinon.stub(deviceProtectionCommands, '_flashBootloader').resolves();

// Call the method
await deviceProtectionCommands.enableProtection();

expect(deviceProtectionCommands._getDeviceProtection).to.have.been.calledOnce;
Expand Down

0 comments on commit fbdfd5b

Please sign in to comment.