Fix code style in tests

Upgrade test dependencies
This commit is contained in:
Martin Endler
2020-01-24 22:31:14 +01:00
parent 9335a6ccc0
commit a43ad505f1
3 changed files with 363 additions and 1202 deletions

View File

@@ -3,6 +3,7 @@
<words>
<w>pcsc</w>
<w>pcsclite</w>
<w>picc</w>
</words>
</dictionary>
</component>

View File

@@ -1,19 +1,27 @@
const { describe, it } = require('mocha');
const should = require('should');
const sinon = require('sinon');
const pcsc = require('../lib/pcsclite');
describe('Testing PCSCLite private', function() {
describe('#start()', function() {
it('#start() stub', function(done) {
var p = pcsc();
describe('Testing PCSCLite private', function () {
describe('#start()', function () {
it('#start() stub', function (done) {
const p = pcsc();
try {
var stub = sinon.stub(p, 'start').callsFake(function(startCb) {
const stub = sinon.stub(p, 'start').callsFake(function (startCb) {
startCb(undefined, Buffer.from("ACS ACR122U PICC Interface\u0000ACS ACR122U PICC Interface 01\u0000\u0000"));
});
var readerHit = 0;
p.on('reader', function(reader) {
let readerHit = 0;
p.on('reader', function (reader) {
reader.close();
switch (++readerHit) {
@@ -25,19 +33,23 @@ describe('Testing PCSCLite private', function() {
done();
break;
}
});
} finally {
p.close();
}
});
});
});
describe('Testing CardReader private', function() {
describe('Testing CardReader private', function () {
var get_reader = function() {
var p = pcsc();
var stub = sinon.stub(p, 'start').callsFake(function(my_cb) {
const get_reader = function () {
const p = pcsc();
const stub = sinon.stub(p, 'start').callsFake(function (my_cb) {
/* "MyReader\0" */
my_cb(undefined, Buffer.from("MyReader\u0000\u0000"));
});
@@ -45,18 +57,16 @@ describe('Testing CardReader private', function() {
return p;
};
describe('#_connect()', function() {
describe('#_connect()', function () {
it('#_connect() success', function(done) {
var p = get_reader();
p.on('reader', function(reader) {
var connect_stub = sinon.stub(reader, '_connect').callsFake(function(share_mode,
protocol,
connect_cb) {
it('#_connect() success', function (done) {
const p = get_reader();
p.on('reader', function (reader) {
const connect_stub = sinon.stub(reader, '_connect').callsFake(function (share_mode, protocol, connect_cb) {
connect_cb(undefined, 1);
});
reader.connect(function(err, protocol) {
reader.connect(function (err, protocol) {
should.not.exist(err);
protocol.should.equal(1);
done();
@@ -64,13 +74,11 @@ describe('Testing CardReader private', function() {
});
});
it('#_connect() error', function(done) {
var p = get_reader();
p.on('reader', function(reader) {
var cb = sinon.spy();
var connect_stub = sinon.stub(reader, '_connect').callsFake(function(share_mode,
protocol,
connect_cb) {
it('#_connect() error', function (done) {
const p = get_reader();
p.on('reader', function (reader) {
const cb = sinon.spy();
const connect_stub = sinon.stub(reader, '_connect').callsFake(function (share_mode, protocol, connect_cb) {
connect_cb("");
});
@@ -80,10 +88,10 @@ describe('Testing CardReader private', function() {
});
});
it('#_connect() already connected', function(done) {
var p = get_reader();
p.on('reader', function(reader) {
var cb = sinon.spy();
it('#_connect() already connected', function (done) {
const p = get_reader();
p.on('reader', function (reader) {
const cb = sinon.spy();
reader.connected = true;
reader.connect(cb);
@@ -96,15 +104,14 @@ describe('Testing CardReader private', function() {
});
describe('#_disconnect()', function() {
describe('#_disconnect()', function () {
it('#_disconnect() success', function(done) {
var p = get_reader();
p.on('reader', function(reader) {
it('#_disconnect() success', function (done) {
const p = get_reader();
p.on('reader', function (reader) {
reader.connected = true;
var cb = sinon.spy();
var connect_stub = sinon.stub(reader, '_disconnect').callsFake(function(disposition,
disconnect_cb) {
const cb = sinon.spy();
const connect_stub = sinon.stub(reader, '_disconnect').callsFake(function (disposition, disconnect_cb) {
disconnect_cb(undefined);
});
@@ -114,12 +121,12 @@ describe('Testing CardReader private', function() {
});
});
it('#_disconnect() error', function(done) {
var p = get_reader();
p.on('reader', function(reader) {
it('#_disconnect() error', function (done) {
const p = get_reader();
p.on('reader', function (reader) {
reader.connected = true;
var cb = sinon.spy();
var connect_stub = sinon.stub(reader, '_disconnect').callsFake(function(disposition,
const cb = sinon.spy();
const connect_stub = sinon.stub(reader, '_disconnect').callsFake(function (disposition,
disconnect_cb) {
disconnect_cb("");
});
@@ -130,12 +137,11 @@ describe('Testing CardReader private', function() {
});
});
it('#_disconnect() already disconnected', function(done) {
var p = get_reader();
p.on('reader', function(reader) {
var cb = sinon.spy();
var connect_stub = sinon.stub(reader, '_disconnect').callsFake(function(disposition,
disconnect_cb) {
it('#_disconnect() already disconnected', function (done) {
const p = get_reader();
p.on('reader', function (reader) {
const cb = sinon.spy();
const connect_stub = sinon.stub(reader, '_disconnect').callsFake(function (disposition, disconnect_cb) {
disconnect_cb(undefined);
});
@@ -147,4 +153,5 @@ describe('Testing CardReader private', function() {
});
});
});
});

1311
yarn.lock

File diff suppressed because it is too large Load Diff