Sha256: 3bbb217bf2dcbaca1a65e026401f72370e2e943f444d2405766f150425f09bc9

Contents?: true

Size: 1.72 KB

Versions: 3

Compression:

Stored size: 1.72 KB

Contents

describe('MonotypeScript', function () {
  var MonotypeScript = webfont.MonotypeScript,
      Font = webfont.Font,
      BrowserInfo = webfont.BrowserInfo,
      UserAgent = webfont.UserAgent;

  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', '3.6', 'Gecko', '1.9.3', 'Macintosh', '10.6', undefined, new BrowserInfo(true, false, false));

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

    global[MonotypeScript.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

3 entries across 3 versions & 1 rubygems

Version Path
webfontloader-1.4.3 spec/monotype/monotypescript_spec.js
webfontloader-1.4.2 spec/monotype/monotypescript_spec.js
webfontloader-1.4.1 spec/monotype/monotypescript_spec.js