ITF.test.js 987 B

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