Sha256: cbada6af16c094fa8798c69c3213ffc5f7ef56b0f12e71c90da695b132c279ad

Contents?: true

Size: 1.64 KB

Versions: 4

Compression:

Stored size: 1.64 KB

Contents

describe('MonotypeScript', function () {
  var MonotypeScript = webfont.MonotypeScript,
      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 ['aachen bold', '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([undefined, undefined], {});
  });
});

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
webfontloader-1.4.0 spec/monotype/monotypescript_spec.js
webfontloader-1.3.2 spec/monotype/monotypescript_spec.js
webfontloader-1.3.1 spec/monotype/monotypescript_spec.js
webfontloader-1.3.0 spec/monotype/monotypescript_spec.js