Skip to content

Commit

Permalink
t2 restore: stub for controlTransfer
Browse files Browse the repository at this point in the history
Signed-off-by: Rick Waldron <waldron.rick@gmail.com>
  • Loading branch information
rwaldron committed Sep 19, 2016
1 parent eb1c839 commit 1630e45
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions test/unit/restore.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ exports['Tessel.prototype.restore'] = {
this.restore = this.sandbox.spy(Tessel.prototype, 'restore');
this.tick = this.sandbox.stub(Progress.prototype, 'tick');
this.tessel = TesselSimulator();

this.tessel.usbConnection.device = {
controlTransfer() {}
};
done();
},

Expand Down Expand Up @@ -70,6 +74,7 @@ exports['Tessel.prototype.restore'] = {
return Promise.resolve();
});


this.tessel.restore({})
.then(() => {
test.equal(this.fetchRestore.callCount, 1);
Expand Down Expand Up @@ -209,9 +214,11 @@ exports['restore.transaction'] = {
callback(null, this.usb.epIn._mockbuffer);
});
this.usb.epIn._mockdata = new Buffer('mockbuffer');
this.usb.device = {
controlTransfer() {}
};

this.expectedBuffer = new Buffer([0x00, 0x00, 0x00, 0x00, 0xFF]);

done();
},

Expand Down Expand Up @@ -337,6 +344,9 @@ exports['restore.bulkEraseFlash'] = {
this.warn = this.sandbox.stub(log, 'warn');
this.info = this.sandbox.stub(log, 'info');
this.usb = new USB.Connection({});
this.usb.device = {
controlTransfer() {}
};

this.transaction = this.sandbox.stub(restore, 'transaction', () => Promise.resolve());
this.waitTransactionComplete = this.sandbox.stub(restore, 'waitTransactionComplete', () => Promise.resolve());
Expand Down Expand Up @@ -400,6 +410,10 @@ exports['restore.flash'] = {
});
this.usb.epIn._mockdata = new Buffer('mockbuffer');

this.tessel.usbConnection.device = {
controlTransfer() {}
};

this.tick = this.sandbox.stub(Progress.prototype, 'tick');
this.expectedBuffer = new Buffer([0x00, 0x00, 0x00, 0x00, 0xFF]);
done();
Expand All @@ -412,7 +426,9 @@ exports['restore.flash'] = {
},

completeRestoreCallSteps(test) {
test.expect(10);
test.expect(11);

this.controlTransfer = this.sandbox.stub(this.tessel.usbConnection.device, 'controlTransfer');

restore.flash(this.tessel, this.images).then(() => {
test.equal(this.partition.callCount, 1);
Expand All @@ -429,6 +445,14 @@ exports['restore.flash'] = {
test.equal(this.write.getCall(2).args[1], 0x50000);
test.equal(this.write.getCall(2).args[2], this.images.squashfs);

test.equal(this.controlTransfer.callCount, 1);
/*
Take a look at other tests in this file
- What was controlTransfer called with?
*/
test.done();
});
},
Expand Down

0 comments on commit 1630e45

Please sign in to comment.