node-bcc
Version:
A simple Block Check Character library.
37 lines • 1.45 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const chai_1 = require("chai");
const sinon = require("sinon");
const helper_1 = require("../helper");
const bcc_1 = require("./bcc");
/* eslint-disable @typescript-eslint/no-explicit-any */
describe('Bcc', () => {
let sandbox;
let checkArrayStub;
beforeEach(() => {
sandbox = sinon.createSandbox();
checkArrayStub = sandbox.stub(helper_1.Helper, 'checkArray');
});
afterEach(() => {
sandbox.restore();
});
describe('calculate', () => {
it('should return null if Helper.checkArray returns false', () => {
checkArrayStub.returns(false);
chai_1.expect(bcc_1.Bcc.calculate([])).to.equal(-1);
});
it('should return correctly calculated BCC with string array', () => {
checkArrayStub.returns(true);
chai_1.expect(bcc_1.Bcc.calculate(['01', '02', '03', '04'])).to.equal(4);
});
it('should return correctly calculated BCC with number array', () => {
checkArrayStub.returns(true);
chai_1.expect(bcc_1.Bcc.calculate([1, 2, 3, 4])).to.equal(4);
});
it('should return crrectly calculated BCC with buffer', () => {
checkArrayStub.returns(true);
chai_1.expect(bcc_1.Bcc.calculate(Buffer.from([1, 2, 3, 4]))).to.equal(4);
});
});
});
//# sourceMappingURL=bcc.spec.js.map