'use strict';

describe('font_post', function() {
  var font2154 = decodeFontData('[encoded data, 5648 characters]');
  var font1282 = decodeFontData('[encoded data, 32908 characters]');
  describe('OS/2 table removal on bad post table values', function() {
    it('has invalid version number', function(done) {
      var font = new Font("font", new Stream(font2154), {
        loadedName: 'font',
        type: 'TrueType',
        differences: [],
        defaultEncoding: [],
        toUnicode: new ToUnicodeMap([])
      });
      ttx(font.data, function(output) {
        verifyTtxOutput(output);
        expect(/<OS_2>\s*<version value="3"\/>/.test(output)).toEqual(true);
        done();
      });
    });

    it('has invalid selection attributes presence', function(done) {
      CMapFactory.create(new Name('Identity-H')).then(function (cMap) {
        var font = new Font("font", new Stream(font1282), {
          loadedName: 'font',
          type: 'CIDFontType2',
          differences: [],
          defaultEncoding: [],
          cMap: cMap,
          toUnicode: new ToUnicodeMap([])
        });
        ttx(font.data, function(output) {
          verifyTtxOutput(output);
          expect(/<OS_2>\s*<version value="3"\/>/.test(output)).toEqual(true);
          done();
        });
      });
    });
  });
});
