UNPKG

node-bcc

Version:

A simple Block Check Character library.

35 lines 1.4 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const chai_1 = require("chai"); const sinon = require("sinon"); const ascii_1 = require("./ascii"); describe('Ascii', () => { describe('asciiToByteArray', () => { let sandbox; let validateStub; beforeEach(() => { sandbox = sinon.createSandbox(); validateStub = sandbox.stub(ascii_1.Ascii, 'validate'); }); afterEach(() => { sandbox.restore(); }); it('should return correct array when only valid chars in input', () => { validateStub.returns(true); chai_1.expect(ascii_1.Ascii.asciiToByteArray('ABC')).to.deep.equal([0x41, 0x42, 0x43]); }); it('should replace non-ASCII chars with SUB character', () => { validateStub.returns(false); chai_1.expect(ascii_1.Ascii.asciiToByteArray('ABC')).to.deep.equal([0x1a, 0x1a, 0x1a]); }); }); describe('validate', () => { it('should return true when string only contains ASCII chars', () => { chai_1.expect(ascii_1.Ascii.validate('SomeString')).to.be.true; }); it('should return false when string contains non-ASCII chars', () => { chai_1.expect(ascii_1.Ascii.validate('So much £££!')).to.be.false; }); }); }); //# sourceMappingURL=ascii.spec.js.map