pharmacode.test.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. var assert = require('assert');
  2. var JsBarcode = require('../../bin/JsBarcode.js');
  3. var Canvas = require("canvas");
  4. describe('Pharmacode', function() {
  5. it('should be able to include the encoder(s)', function () {
  6. Pharmacode = JsBarcode.getModule("pharmacode");
  7. });
  8. it('should be able to encode normal text', function () {
  9. var enc = new Pharmacode("1234", {});
  10. assert.equal("10010011100111001001110010010011100111"
  11. , enc.encode().data);
  12. var enc = new Pharmacode("4567", {});
  13. assert.equal("10010010011100111001110010011100111001001001"
  14. , enc.encode().data);
  15. var enc = new Pharmacode("12", {});
  16. assert.equal("11100100111", enc.encode().data);
  17. });
  18. it('should return getText correct', function () {
  19. var enc = new Pharmacode("1234", {});
  20. assert.equal("1234", enc.encode().text);
  21. });
  22. it('should warn with invalid text', function () {
  23. var enc = new Pharmacode("12345678", {});
  24. assert.equal(false, enc.valid());
  25. });
  26. it('should work with text option', function () {
  27. var enc = new Pharmacode("12345678", {text: "THISISTEXT"});
  28. assert.equal("THISISTEXT", enc.encode().text);
  29. });
  30. });