'use strict';

describe('font_post', function() {
  var font2109 = decodeFontData('[encoded data, 25084 characters]');
  var font2189 = decodeFontData('[encoded data, 17324 characters]');
  var font2374 = decodeFontData('[encoded data, 31336 characters]');
  describe('post table removal on bad post table values', function() {
    it('has invalid version number', function() {
      var output;
      waitsFor(function() { return output; }, 10000);
      var font = new Font("font", new Stream(font2109), {
        loadedName: 'font',
        type: 'CIDFontType2',
        differences: [],
        baseEncoding: []
      });
      ttx(font.data, function(result) { output = result; });
      runs(function() {
        verifyTtxOutput(output);
        expect(/<post>\s*<formatType value="3\.0"\/>/.test(output)).toEqual(true);
      });
    });

    it('has invalid glyph name indexes', function() {
      var output;
      waitsFor(function() { return output; }, 10000);
      var font = new Font("font", new Stream(font2189), {
        loadedName: 'font',
        type: 'TrueType',
        differences: [],
        baseEncoding: []
      });
      ttx(font.data, function(result) { output = result; });
      runs(function() {
        verifyTtxOutput(output);
        expect(/<post>\s*<formatType value="3\.0"\/>/.test(output)).toEqual(true);
      });
    });

    it('has right amount of glyphs specified', function() {
      var output;
      waitsFor(function() { return output; }, 10000);
      var font = new Font("font", new Stream(font2374), {
        loadedName: 'font',
        type: 'TrueType',
        differences: [],
        baseEncoding: []
      });
      ttx(font.data, function(result) { output = result; });
      runs(function() {
        verifyTtxOutput(output);
        expect(/<post>\s*<formatType value="3\.0"\/>/.test(output)).toEqual(true);
      });
    });
  });
});
