Sha256: 308e04afd80c6a8e5307342695cf55a2b1d135719337fb17d270eb5717968904

Contents?: true

Size: 1.87 KB

Versions: 5

Compression:

Stored size: 1.87 KB

Contents

describe('modules.Monotype', function () {
  var Monotype = webfont.modules.Monotype,
      Font = webfont.Font,
      BrowserInfo = webfont.BrowserInfo,
      UserAgent = webfont.UserAgent,
      Version = webfont.Version;

  var configuration = {
    projectId: '01e2ff27-25bf-4801-a23e-73d328e6c7cc',
    api: 'http://fast.fonts.com/jsapidev'
  };

  var fakeDomHelper = null,
      global = null,
      script = {},
      monotype = null,
      load =  null,
      useragent = null,
      support = null;

  beforeEach(function () {
    global = {};

    fakeDomHelper = {
      createElement: jasmine.createSpy('createElement').andReturn(script),
      insertInto: jasmine.createSpy('insertInto'),
      getLoadWindow: jasmine.createSpy('getLoadWindow').andReturn(global),
      getProtocol: jasmine.createSpy('getProtocol').andReturn('http:')
    };
    support = jasmine.createSpy('support');
    load = jasmine.createSpy('load');
    useragent = new UserAgent(
      'Firefox',
      new Version(3, 6),
      '3.6',
      'Gecko',
      new Version(1, 9, 3),
      '1.9.3',
      'Macintosh',
      new Version(10, 6),
      '10.6',
      undefined,
      new BrowserInfo(true, false, false)
    );

    monotype = new Monotype(useragent, fakeDomHelper, configuration);
    monotype.supportUserAgent(useragent, support);
    monotype.load(load);

    global[Monotype.HOOK + configuration.projectId] = function () {
      return [{fontfamily: 'aachen bold'}, {fontfamily: 'kid print regular'}];
    };

    script.onload();
  });


  it('should create a script element', function () {
    expect(support).toHaveBeenCalled();
    expect(fakeDomHelper.createElement).toHaveBeenCalledWith('script');
    expect(script.src).toEqual('http://fast.fonts.com/jsapidev/01e2ff27-25bf-4801-a23e-73d328e6c7cc.js');
    expect(load).toHaveBeenCalledWith([new Font('aachen bold'), new Font('kid print regular')]);
  });
});

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
webfontloader-1.4.9 spec/modules/monotype_spec.js
webfontloader-1.4.8 spec/modules/monotype_spec.js
webfontloader-1.4.7 spec/modules/monotype_spec.js
webfontloader-1.4.6 spec/modules/monotype_spec.js
webfontloader-1.4.5 spec/modules/monotype_spec.js